Multiple plots in one m file

27 ビュー (過去 30 日間)
D.J
D.J 2018 年 9 月 3 日
回答済み: D.J 2018 年 9 月 3 日
Hello all, my .m file includes multiple plots. When I run the code only the last plot figure shows up and overwrites all previous plots. Any suggestion on how to manage this ?
Many thanks
  1 件のコメント
jonas
jonas 2018 年 9 月 3 日
編集済み: jonas 2018 年 9 月 3 日
How do you initate a figure? Some code would be useful here.

サインインしてコメントする。

採用された回答

Gabor Balazs
Gabor Balazs 2018 年 9 月 3 日
Your first plot command opens a figure and all following plot commands update that figure. To open new figure windows, use
figure()
for each window you want to open.
figure(1)
plot(1:10)
figure(2)
mesh(randn(10))

その他の回答 (2 件)

Dimitris Kalogiros
Dimitris Kalogiros 2018 年 9 月 3 日
Before using plot() command you should place a "figure" command
For example:
clc; clear; close all;
t=0:0.1:10;
x=sin(2*pi*3.*t);
y=sqrt(t)+cos(2*pi.*t);
figure;
plot(t,x,'-b'); zoom on; grid on;
figure;
plot(t,y,'-r'); zoom on; grid on;

D.J
D.J 2018 年 9 月 3 日
Wonderful, thanks a lot for your quick help !

カテゴリ

Help Center および File ExchangeVisual Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by