Plotting seperate figure in for loop

조회 수: 2 (최근 30일)
sam moor
sam moor 2017년 2월 23일
댓글: sam moor 2017년 2월 23일
I have matlab script which gives me a vector( name as PSa) of 3991x44. I do have another vector (name as PSa_avg) of 3991x1 (it's average of PSa). Now, I have vector T of 1x3991. Now, I want to have a for loop for PSa so that I can plot each column of PSa with T and then in same plot I would like to plot PSa_avg with T and so on for all 44 columns in 44 figure using for loop. Let me know your suggestions. Thank you.
  댓글 수: 2
Chad Greene
Chad Greene 2017년 2월 23일
There's some conflicting information in your question. You say something about wanting separate figures, but you also mention "in same plot". Can you be more clear? Can you upload example data? Also, you mention loops several times--are loops required, and if so, why?
sam moor
sam moor 2017년 2월 23일
I mean I want to plot 44 figures using for loop(i.e. T Vs PSA )and in all 44 figures I also want to plot T vs PSA_avg

댓글을 달려면 로그인하십시오.

채택된 답변

Peter O
Peter O 2017년 2월 23일
44 separate figures? Be aware that this many figures can make MATLAB unhappy to the point of Java crashing, particularly on lower memory systems or those without a dedicated video card. But it's easy to accomplish in a for loop:
n = size(PSa,2)
for ix=1:n
nm = sprintf('PSa #%u',ix);
fh = figure('Name',sprintf('Data Column %u',ix));
ha = axes('Parent',fh);
plot(ha,T,PSa(:,ix),T,PSa_avg);
title(ha,nm);
legend(ha,nm,'PS Avg');
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by