I want to draw two figure in same figure window for comparison purpose.
2 views (last 30 days)
Show older comments
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.
Answers (1)
Yazan
on 18 Jul 2021
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');
0 Comments
See Also
Categories
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!