I'm trying to create 6 plots with 6 subplots within each. Right now when I run it, it's coming out as 37 individual plots - any idea on where I'm going wrong?
f1=figure;
rose(itc_freq_mean(nfreq,:));
for m=1:6
for k=1:6
h=figure;
hold on
subplot(2,3,k);
itc_freq_plot=(itc_freq_mean(k,:));
rose(itc_freq_mean(k,:));
title(freq_titles{k});
end
end
Thank you in advance!

 채택된 답변

Matt J
Matt J 2019년 2월 4일
편집: Matt J 2019년 2월 4일

0 개 추천

Invoke figure() in the outer loop only,
for m=1:6
figure;
for k=1:6
subplot(2,3,k);
itc_freq_plot=(itc_freq_mean(k,:));
rose(itc_freq_mean(k,:));
title(freq_titles{k});
end
end

댓글 수: 5

Adam Danz
Adam Danz 2019년 2월 4일
편집: Adam Danz 2019년 2월 4일
Actually, the call to figure() needs to be moved to the first for-loop. That way a new figure will be created for each 'm' and 6 subplots will be created within each figure.
for m=1:6
figure();
for k=1:6
%h=figure; %remove this
hold on
subplot(2,3,k);
itc_freq_plot=(itc_freq_mean(k,:));
rose(itc_freq_mean(k,:));
title(freq_titles{k});
end
end
Maria Y
Maria Y 2019년 2월 4일
Thank you for your responses! They both worked, except the 6 plots should be 6 different conditions, and right now all 6 are coming out the same?
Adam Danz
Adam Danz 2019년 2월 4일
That's because nothing changes between the m-loops. For each m-loop you're going through the same k-loops so you'll have the same 6 subplots on each figure.
Got it. The variable itc_freq_mean should loop through the 6 conditions (itc_condition) based on this for loop I wrote earlier:
for nfreq = 1:6
itc_freq_mean(nfreq, :) = circ_mean(squeeze(itc_condition(freq_ind{nfreq}, time_ind, :)));
end
Should I add it somewhere in the m-loop?
Matt J
Matt J 2019년 2월 5일
Only compute k-dependent things in the k-loop.

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

추가 답변 (0개)

카테고리

태그

질문:

2019년 2월 4일

댓글:

2019년 2월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by