Problem: 24.9 use matlab please .. An insulated heated rod with a uniform heat s
ID: 3119082 • Letter: P
Question
Problem: 24.9
use matlab please ..
An insulated heated rod with a uniform heat source can be modeled with the Poisson equation: d^2T/dx^2 = -f(x) Given a heat source f(x) = 25 degree C/m^2 and the boundary conditions T(x = 0) = 40 degree C and T(x = 10) = 200 degree C, solve for the temperature distribution with the shooting method and the finite-difference method (delta x = 2). Repeat Prob. 24.8, but for the following spatially varying heat source: f(x) = 0.12x^3 - 2.4 x^2 + 12x.Explanation / Answer
Matlab code to solve the above problem by Rungue kutta method: function [x y] = shooting_method(fun,h,zero,a,b,con,type,init) tic; if (h 0) error('The root of F function does not exist, for selected initialization parameters. Please, change the init array.') end F3 = F1; while (abs(F3) > zero) shoot3 = (shoot1 + shoot2)/2; if (type(1)=='f') a3 = [con(1) shoot3]; else a3 = [shoot3 con(1)]; end [x, F3] = RungeKutta(a,b,h,a3,fun); y = F3; F3 = F3(r,end) - con(2); if (F1*F3 < 0) shoot2 = shoot3; F2 = F3; elseif (F1*F2 < 0) shoot1 = shoot3; F1 = F3; else error('Selhani metody puleni intervalu, zmente init'); end end h = plot(x,y(1,:),'k-'); set(h,'linewidth',2); hold on; h = plot(x,y(2,:),'r-'); set(h,'linewidth',2); xlabel('{it x}','FontSize',12); ylabel('y({it x }), y^{(1)}({it x })','FontSize',12); title('Solution of 1D Boundary Value Problem by Shooting Method','FontSize',12); set(gca,'FontSize',12); legend('Function','{1^{st}} Derivative','Location','Best'); hold off; toc;Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.