I want to draw two figure in same figure window for comparison purpose.

1 回表示 (過去 30 日間)
chhatra pal
chhatra pal 2021 年 7 月 18 日
回答済み: Yazan 2021 年 7 月 18 日
Hi
I want to draw two figure in same figure window for comparison purpose of two different numerical scheme.
The problem is that I can execute code for one scheme at a time in the same script file Graphs are drawn Then I want draw graph in the same figure window when I execute code for next scheme in the same script file.
Please suggest me some way for that.
  1 件のコメント
KSSV
KSSV 2021 年 7 月 18 日
Save the data into array and plot at the end.

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

回答 (1 件)

Yazan
Yazan 2021 年 7 月 18 日
See the example below if you want to draw data on the same axes:
% first signal
t = 0:127;
x = cos(2*pi*0.01*t);
% create a figure and axes
% hold the axes
f = figure; ax = axes(f); hold(ax, 'on')
plot(ax, x), grid(ax, 'minor')
% second signal
x = cos(2*pi*0.05*t);
% plot on the same axes
plot(ax, x)
legend(ax, {'Signal 1', 'Signal 2'})
If you want to draw on different axes, then use subplot:
t = 0:127;
x = cos(2*pi*0.01*t);
% first set of axes
subplot(1,2,1);
plot(x), grid('minor');
x = cos(2*pi*0.05*t);
% second set of axes
subplot(1,2,2);
plot(x), grid('minor');

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by