user2482542
user2482542

Reputation: 361

How to plot multiple figures in a for loop in matlab

I wish to implement a for loop that would perform short time fourier series. I'll be using windowing and say I obtain 3 frames on which i wish to perform fft inside a for loop, how can i plot all three graphs?

pos = (1+w_length:w_length:length(wave))-w_length;

for v = pos

data_sub = wave(v:v+w_length);

subsection_fft = fft(data_sub);

end

Upvotes: 0

Views: 754

Answers (1)

PeterM
PeterM

Reputation: 2692

You can create new figures by using the figure function.

  figure
  plot([0 1],[0 .3]);

  figure
  plot([0 1],[0 0.6]);

  figure
  plot([0 1],[0 0.9]);

Or you can put multiple axes in the same figure using the subplot function;

  subplot(3,1,1);
  plot([0 1],[0 .3]);

  subplot(3,1,2);
  plot([0 1],[0 .6]);

  subplot(3,1,3);
  plot([0 1],[0 .9]);

Or you can plot 3 lines in the same axis by using the hold function

  plot([0 1],[0 .3]);
  hold on;

  plot([0 1],[0 .6]);

  plot([0 1],[0 .9]);

Upvotes: 2

Related Questions