MATLAB only plotting most recent graph
3 ビュー (過去 30 日間)
古いコメントを表示
I don't understand why matlab is only plotting figure 2
t0 = 0; tf = 50; y0 = [-0.5;0.5];
[t,Y] = ode45(@f,[t0,tf],y0,[]);
y=Y(:,1);v=Y(:,2);
[t,Y(:,1),Y(:,2)];
% y in output has 2 columns corresponding to u1 and u2
figure(1);
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(2);
plot(y,v); axis square; xlabel('y'); ylabel('v=y''');
ylim([-2.5,2.5])
xlim([-2.5,2.5])
grid on
hold off
% plot the phase plot %----------------------------------------------------------------------
function dydt = f(t,Y)
y = Y(1); v = Y(2);
dydt = [v;-2*sin(t)-v-2*y ];
end
2 件のコメント
dpb
2024 年 7 月 31 日
編集済み: dpb
2024 年 7 月 31 日
Possibly @Anjana doesn't realize that because the second figure identically overlays the first so only sees the second?
@Anjana - select the second and move it and you'll find the first hidden behind it. (I agree that I find it annoying MATLAB doesn't open them with at least a slight offset so you can select without having to first move.)
回答 (1 件)
Jatin
2024 年 8 月 5 日
Hi Anjana,
As we can see we are using default “figure” objects in the code, and all the default figures have same "Position” property. Hence it causes MATLAB to open all default figures at the same location on the screen.
So, you must manually drag the top figure to make the bottom figure visible.
Or you can also set the position of each figure using the “Position” property to manually define the positions of each figure on the screen.
For e.g.,
figure1 = figure('Position', [100, 100, 500, 400]); % [left, bottom, width, height]
figure2 = figure('Position', [650, 100, 500, 400]); % Adjust 'left' to avoid overlap
Kindly refer to the below documentation of “Position” property of “figure” objects for more details:
0 件のコメント
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!