Question

How do I create multiple subplots simultaneously, for example, I have

while i < 4
   kS = kS_array(i);
   bS = bS_array(i);
   sim('sim_1');
   subplot(3,1,i), plot(time,x);
   %now i want to create another subplot for F(force wrt time)
   % something like subplot_2(3,1,i), plot(time, F)
   i=i+1;
end

I am simulating simulink model with different variables and plotting them. I am a beginner so I want to know if there is any other efficient way to do this.

Was it helpful?

Solution

found the answer

figure1 = figure; figure2 = figure;
while i < 4
   kS = kS_array(i);
   bS = bS_array(i);
   sim('sim_1');
   set(0, 'currentfigure', figure1);
   subplot(3,1,i), plot(time,x);
   set(0, 'currentfigure', figure2);
   subplot(3,1,i), plot(time, FT);
   i=i+1;
end

This works the way I want it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top