Question: I keep getting errors in the code when solving this question need help plz , i need Matlab scripts based on the question that can

I keep getting errors in the code when solving this question need help plz, i need Matlab scripts based on the question that can solve them fullscript explanation of your codes did be great thanks, the given script from (A)generate , fix it and generate the other scripts needed.This is the Script NonInsulatedRod Shooting.m%%----------------------------------------------------------------- Inputs
% NOTE: PLEASE SEARCH THE FILE FOR 'TO DO' COMMENT - THESE ARE LINES THAT
% YOU NEED TO MODIFY!!
% Parameters of mathematical model
%TO DO
% System of ODEs
%(store dependent variables in y =[T,z], i.e., y(1)= T and y(2)= z)
% dydx ={dTdx,dzdx})
dTdx = @(x,y)(); %TO DO
dzdx = @(x,y)(); %TO DO
dydx ={dTdx,dzdx};
% Parameters for numerical method
%TO DO
% One-step algorithm for solving IVP
algorithm ='RK4'; %choose 'Euler, 'Heun', 'RK4'
%%----------------------------------------------------- Plot True Solution
% True (linear) solution
%TO DO
% Plot analytical solution
%TO DO
%%---------------------------------------------- Nonlinear Shooting Method
% Define function handle to one-step IVP solver
switch algorithm
case 'Euler', oneStep = @(x,y)EulerSystem(x,y,dydx,h);
case 'Heun', oneStep = @(x,y)HeunSystem(x,y,dydx,h);
case 'RK4', oneStep = @(x,y)RK4System(x,y,dydx,h);
otherwise
error('Algorithm must be ''Euler'',''Heun'', or ''RK4''');
end
% Solve root-finding problem for a
%TO DO - NEED ALGORITHMIC PARAMETERS
f = @(a)boundaryValueMismatch(a); %TO DO - NEED ADDITIONAL INPUTS
%TO DO - CALL TO ROOT FINDING FUNCTION
% Solve IVP with all intermediate values of a and plot solutions
%(Note this is redundant - IVP has already been solved for each value of a
% during root-finding - to keep the implementation simple, we do not worry
% about outputting solutions to the IVP during root-finding and re-solve
% the IVPs here)- use a loop over a
%TO DO
%-----------------------------------------------
Figure 1: Noninsulated uniform rod between two bodies of constant temperature.
Figure 1 shows a schematic of a noninsulated uniform rod length, L=10m, positioned under ambient
temperature, Ta=20C, between two bodies at constant temperatures: TL=40C at the left end and TR=
200C at the right end. A simplified mathematical model of this system at steady state is given by the boundary
value problem (BVP),
d2Tdx2+h'(Ta-T)=0, where T(0)=TL,T(L)=TR
where h'=0.01m-2 is the heat transfer coefficient. Although the ODE in (1) is linear and a linear shooting method
that interpolates between two guesses of the initial value can be used, we consider the more general nonlinear
shooting method in which root-finding is used to find the initial value. Such nonlinear shooting method can be used
for BVPs with linear or nonlinear ODEs.
We seek to solve the BVP in (1) numerically and compare the numerical solutions to the analytical solution,
T(x)=c1e(h'2)x+c2e(-h'2)x+Ta
c1=TL-Ta-c2
c2=TR-TLe(h'2)L--Ta(1-e)(h'2)L?e(-h'2)L-(h'2)L
Taking advantage of the fact that (1) has a unique solution, we seek to solve it using the nonlinear shooting method
in which we treat the problem as an initial value problem (IVP) and iteratively adjust the initial values until the
boundary values of (1) are met. To do so, we convert (1) to a system of first-order IVPs,
dTdx=z,T(0)=TL
dzdx=-h'(Ta-T),z(0)=a
and iterate to find the initial value, a, such that the second boundary value of (1),T(L)=TR, is satisfied. The
associated problem is a root-finding problem in which we seek to find a such that
T(L,a)-TR=0
Goals
Using the provided (incomplete) script, Script NonInsulatedRod Shooting.m, write a modular Matlab code that
solves the BVP in (1) via the system of IVPs in (3) using the nonlinear shooting method and considering h=1.0m.
To do so, please:
(a) Complete the script.
(b) Write a function file, EulerSystem.m, that performs a single step of Euler's method and can be used to solve a
system of first-order IVPs (please see Fig. 3 for a possible function header).
(c) Implement the main iterative loop for one-step methods in a separate function file, iterativelVP-
SolverSystem.m. This function should take as input the initial values of your dependent variable (as a vector),
the initial and final value of your independent variable, and a function handle, onestep, to a one-step method
implemented in (b). Note: This function should require very minor modifications (if any) to a similar function
written for homework 8(please see Fig. 4 for a possible function header).
(d) Write a function file, boundaryValueMismatch.m, that implements the function in (4) for which we wish to
find the root. Since
I keep getting errors in the code when solving

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!