Using Figure
113 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Walter Roberson
le 11 Déc 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 commentaires
Plus de réponses (1)
Paulo Silva
le 11 Déc 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 commentaires
Voir également
Catégories
En savoir plus sur Specifying Target for Graphics Output dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!