Using Figure

113 Ansichten (letzte 30 Tage)
Villanova
Villanova am 11 Dez. 2011
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 11 Dez. 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

Weitere Antworten (1)

Paulo Silva
Paulo Silva am 11 Dez. 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')

Kategorien

Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by