Question: MATLAB clear all; close all a = 0; b = 0; c = 0; d = 0; J = [a b; c d]; eigs(J) t0
MATLAB
clear all; close all
a = 0; b = 0; c = 0; d = 0;
J = [a b; c d];
eigs(J)
t0 = 0;
tf = 10;
x0 = .1;
y0 = .1;
[t,u] = ode45(@(t,u) lab6fun(t,u,a,b,c,d), [t0 tf], [x0 y0]);
x = u(:,1);
y = u(:,2);
%%
set(0,'DefaultAxesFontSize',24)
figure(1)
hold on
plot(x,y,'k','linewidth',3)
plot(x0,y0,'go','MarkerSize',12,'MarkerFaceColor','g')
xlabel('x') ylabel('y') figure(2)
hold on
plot(t,x,'b','linewidth',3)
plot(t,y,'r--','linewidth',3)
xlabel('t') legend('x','y') legend('boxoff') //////////////////////////////////////////////////////////////////
function z = lab6fun(t,u,a,b,c,d)
x=u(1);
y=u(2);
z(1) = a*x + b*y;
z(2) = c*x + d*y;
z=z';
BASED ON THIS CODE , code up the forward euler method given the formula Xn+1=Xn+F(xn)delta t
compare time courses of x(t) vs t from those using ODE45 and your coded up forward euler scheme from 2-4 , do these for different choices of delta t . Use the subplotcommand in MATLAB and create detailed legends so as to keep the total numbers of plots to a minimun.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
