Info

此问题已关闭。 请重新打开它进行编辑或回答。

MATLAB only opening up most recent plot

1 次查看(过去 30 天)
Anjana
Anjana 2024-7-31
关闭: John D'Errico 2024-7-31
MATLAB only opens figure 4, not figure 3
t0 = 0; tf = 50; y0 = [-2;-1.7];
[t,Y] = ode45(@f,[t0,tf],y0,[]);
y=Y(:,1);v=Y(:,2);
[t,Y(:,1),Y(:,2)];
figure(3);
plot(t, y,'b-', t,v,'r-' )
xlabel('t'); ylabel('y, v = y''');
legend('y(t)','v(t)')
ylim([-2.5,2.5]);xticks(0:10:50);
grid on
figure(4);
plot(y,v); axis square; xlabel('y'); ylabel('v=y''');
ylim([-2.5,2.5])
xlim([-2.5,2.5])
grid on
% plot the phase plot %----------------------------------------------------------------------
function dydt = f(t,Y)
y = Y(1); v = Y(2);
dydt = [v;-2*sin(t)-v-2*y ];
end

回答(0 个)

此问题已关闭。

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by