Using Figure
113 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I remember there was a command to plot multiple graphs on seperate plots. Does anyone know how you do that:
figure(1)
plot(t,x(:,1),'red','linewidth',2 )
xlabel('Time (s)');
ylabel('X_1');
figure (2)
plot(t,x(:,2),'blue','linewidth',2 )
xlabel('Time (s)');
ylabel('X_2');
I know it has to do with 'Figure' command on the fist line. Thanks
0 Commenti
Risposta accettata
Walter Roberson
il 11 Dic 2011
h1 = figure(1);
ax1 = axes('Parent', h1);
plot(ax1, t,x(:,1),'red','linewidth',2 )
xlabel(ax1, 'Time (s)');
ylabel(ax1, 'X_1');
h2 = figure(2);
ax2 = axes('Parent', h2);
plot(ax2, t,x(:,2),'blue','linewidth',2 )
xlabel(ax2, 'Time (s)');
ylabel(ax2, 'X_2');
I explain why to explicitly parent graphics in my comment in http://www.mathworks.com/matlabcentral/answers/22208-show-figure
0 Commenti
Più risposte (1)
Paulo Silva
il 11 Dic 2011
doc subplot
example
t=0.01:0.01:1;
x=rand(100,2);
subplot(211)
plot(t,x(:,1),'red','linewidth',2 )
xlabel('Time (s)');
ylabel('X_1');
subplot(212)
plot(t,x(:,2),'blue','linewidth',2 )
xlabel('Time (s)');
ylabel('X_2');
another way
t=0.01:0.01:1;
x=rand(100,2);
clf
hold on
plot(t,x(:,1),'red','linewidth',2 )
xlabel('Time (s)');
ylabel('X');
plot(t,x(:,2),'blue','linewidth',2 )
xlabel('Time (s)');
ylabel('X');
legend('X_1','X_2')
0 Commenti
Vedere anche
Categorie
Scopri di più su Specifying Target for Graphics Output in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!