MATLAB: Using Figure

figure

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

Best Answer

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
Related Question