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

4 vues (au cours des 30 derniers jours)
chhatra pal
chhatra pal le 18 Juil 2021
Réponse apportée : Yazan le 18 Juil 2021
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.

Réponses (1)

Yazan
Yazan le 18 Juil 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');

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by