フィルターのクリア

Only the most recent graph showing up?

59 ビュー (過去 30 日間)
briana chen
briana chen 2020 年 12 月 7 日
コメント済み: briana chen 2020 年 12 月 7 日
I am using the web version of MATLAB and when I try to plot 2 graphs, only the most recent one shows up. For example, what I have below would only show plot(t,s). no other figure or graph shows up. Why is that? Is there any way to fix this?
Any help is much appreciated! Thank you
plot(t,c)
plot(t,s)
  2 件のコメント
Ive J
Ive J 2020 年 12 月 7 日
figure;
plot(t, c)
figure;
plot(t, s)
or use subplot.
briana chen
briana chen 2020 年 12 月 7 日
Thank you so much Ive Ive!

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

採用された回答

Harry Laing
Harry Laing 2020 年 12 月 7 日
編集済み: Harry Laing 2020 年 12 月 7 日
When you call the 'plot' function, without any other arguments, MATLAB will automatically plot the most recent request on the current figure, overwriting previously plotted data. If you wish the plotted data to appear on the same figure, I suggest using the 'hold' command (it means matlab won't wipe the figure each time you want to plot on it):
% Call a figure to be created
figure;
plot(t,c) % Plot first graph
hold on % prevents matlab overwriting current figure data
plot(t,s) % plot second figure
hold off % turns the hold off
Don't forget to turn the hold off, as it can (sometimes) have unexpected results later on with your code.
Alternatively, if you want the two plots on seperate figures, you should either call a new figure to be created each time, or use 'subplot' to plot multiple graphs on one figure:
% Example plot on two seperate figures
figure;
plot(t,c)
figure;
plot(t,s)
hold off
% Example plot for two seperate graphs on one figure
figure;
subplot (2,1,1)
plot(t,c)
subplot(2,1,2)
plot(t,s)
I reccomend you read the documentation on subplot as to how the layout works.
  1 件のコメント
briana chen
briana chen 2020 年 12 月 7 日
Wow, thank you so much for this detailed answer! It helped so much and has solved my issue :) Have a great day!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by