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

1 次查看(过去 30 天)
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 个)

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 CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by