plotting a phase plane with a system of linear diff equations.
조회 수: 6 (최근 30일)
이전 댓글 표시
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
채택된 답변
Star Strider
2021년 7월 28일
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!