Attached is an image of the problem I am dealing with. I am extremely lost on ho
ID: 2970760 • Letter: A
Question
Attached is an image of the problem I am dealing with. I am extremely lost on how to write the coding in MATLAB to generate the required graphs for the following ODE's. Please provide a detailed coding for MATLAB!
A classical ODE system can be described by three odes. The equations are Here sigma, r, b are all positive parameters. Consider the scenario that sigma = 10, b = 8/3, r = 28. Try to solve this ode with the initial condition to be [0,1,0) with t to be long enough. Then Ploty vs t. Look at the figure and try to describe what you observed. Hint: do you see a pattern? Hint: think again, is it really a pattern? Maybe try to run it longer? Plot z vs x. Look at the figure and try to describe what you observed. Hint: Do you see a pattern? Hint: think again. Plot x vs y vs z in 3D. Describe what you see.Explanation / Answer
%run this code by copying i a matlab file and for plotting in 3-d use plot tools
% dx/dt = 10*(y-x); dy/dt = 28x-y-xz; dz/dt = xy-(8/3)z;
%using forward difference euler method for numerical solving.i.e
%dx/dt=(x(i+1)-x(i))/dt;
%dy/dt=(y(i+1)-y(i))/dt;
%dz/dt=(z(i+1)-z(i))/dt;
clc
clear all
dt=0.01;
t(1)=0;
x(1)=0;
y(1)=1;
z(1)=0;
for i=1:1000
t(i+1)=t(i)+dt;
x(i+1)=x(i)+10*(y(i)-x(i))*dt;
y(i+1)=y(i)+(28*x(i)-y(i)-x(i)*z(i))*dt;
z(i+1)=z(i)+(x(i)*y(i)-(8/3)*z(i))*dt;
fprintf('x(%d)=%f -> y(%d)=%f ->z(%d)=%f ',i,x(i),i,y(i),i,z(i));
end;
p=plot(x,t);
hold all;
q=plot(y,t);
hold all;
o=plot(z,t);
hold all;
title('plots in 2-d');
xlabel('t-axis');
ylabel('Function Value of x,y,z');
set(p,'Color','red','LineWidth',1)
set(q,'Color','green','LineWidth',1)
set(o,'Color','blue','LineWidth',1)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.