Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

QUESTION 8 Consider the ordinary differential equation whereOsts2 and with initi

ID: 3198680 • Letter: Q

Question

QUESTION 8 Consider the ordinary differential equation whereOsts2 and with initial condition (o)2 (a) Write a MATLAB function odelt.n of the variables t and X which implements the right hand side of the equation. Upload your function in the link at the end of this question You must call the function odelt.m and you must include a comment line if this file (a line starting with %) which contains your lD number Failure to do this may result in your answer not checked (b) Write a script which you must call ode1q.m in which you L use the function ode45 to find a numerical solution to the differential equation above in the range Osts 2 and initial condition x(o)2 u displays the graph of the numerical solution with t on the horizonti axis and Xon the vertical axis Upload your file in the link in the next question, You must include a comment line with your ID number in this file Attach Fe Browse My Computer Browse Content Collection

Explanation / Answer

%Function
function f=ode1f(t,x)
if x>=t
f=t^3+x;
else
f=(x^2+1)*t;
end

end

% This is the SCRIPT
tspan = [0 2];
x0 = -2;
[t,x] = ode45(@ode1f, tspan, x0);

plot(t,x)
xlabel('t');
ylabel('x');

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote