plotting a phase plane with a system of linear diff equations.
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Bryan Proa
il 27 Lug 2021
Commentato: Star Strider
il 28 Lug 2021
Hi,
I have this system of differential equations(at the very bottom), and I'm not sure how to go about plotting a phase plane. Something that looks like the graph below.(This is just an example for another set of equations.)
syms u(t) v(t)
ode1 = diff(u) == ((1/40)*v)-(u*(9/100))
ode2 = diff(v) == (u*(9/100))-(v*(9/200))
0 Commenti
Risposta accettata
Star Strider
il 28 Lug 2021
Using the numeric ODE solvers, likely the easiest way to do that is to use odeset to set options, and then choose 'OutputFcn', @odephas2 as described in the documentation section on Solver Output .
syms u(t) v(t) t Y
ode1 = diff(u) == ((1/40)*v)-(u*(9/100))
ode2 = diff(v) == (u*(9/100))-(v*(9/200))
[VF,Sbs] = odeToVectorField(ode1,ode2)
ode12fcn = matlabFunction(VF, 'Vars',{t,Y})
% ic = randn(2,1)
ic = [-0.4 0.2]
[t,y] = ode45(ode12fcn,[0 100], ic);
for k = 1:numel(t)
dy(:,k) = ode12fcn(t(k),y(k,:));
end
figure
plot(y(:,1), y(:,2))
grid
xlabel('y_1')
ylabel('y_2')
figure
quiver(y(:,1), y(:,2), dy(1,:).',dy(2,:).')
grid
xlabel('y_1')
ylabel('y_2')
opts = odeset('OutputFcn', @odephas2);
figure
[t,y] = ode45(ode12fcn,[0 100], ic, opts);
figure
plot(t, y)
grid
xlabel('t')
ylabel('y')
legend(string(Sbs))
That is the essential approach.
I will defer to you for the rest.
.
2 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!