How do I solve the construct marices of multiple variables and plot a graph
I am a beginner to MATLAB.
I tried but I’m getting errors.
Anybody, kindly help. Thank you.
Equations dx/dt=-2x
dy/dt=2x
Initial condition: x(t=0)=100
y(t=0)=0
tspan=[0 3];
x0=100;
y0=0;
dzdt = (dxdt dydt);
[tSol, zSol]=ode45(@odefun,tspan,x0);
plot(tSol, zSol);
function dzdt=odefun(t,z)
x = z(1);
y = z(2);
dxdt = -2*x;
dydt = 2*x;
dzdt = [dxdt;dydt];
endI am a beginner to MATLAB.
I tried but I’m getting errors.
Anybody, kindly help. Thank you.
Equations dx/dt=-2x
dy/dt=2x
Initial condition: x(t=0)=100
y(t=0)=0
tspan=[0 3];
x0=100;
y0=0;
dzdt = (dxdt dydt);
[tSol, zSol]=ode45(@odefun,tspan,x0);
plot(tSol, zSol);
function dzdt=odefun(t,z)
x = z(1);
y = z(2);
dxdt = -2*x;
dydt = 2*x;
dzdt = [dxdt;dydt];
end I am a beginner to MATLAB.
I tried but I’m getting errors.
Anybody, kindly help. Thank you.
Equations dx/dt=-2x
dy/dt=2x
Initial condition: x(t=0)=100
y(t=0)=0
tspan=[0 3];
x0=100;
y0=0;
dzdt = (dxdt dydt);
[tSol, zSol]=ode45(@odefun,tspan,x0);
plot(tSol, zSol);
function dzdt=odefun(t,z)
x = z(1);
y = z(2);
dxdt = -2*x;
dydt = 2*x;
dzdt = [dxdt;dydt];
end ode MATLAB Answers — New Questions