How to continue subplot within for loop to another for loop?

조회 수: 3 (최근 30일)
Fahmy Shandy
Fahmy Shandy 2019년 12월 18일
답변: Walter Roberson 2019년 12월 18일
I'm referring to this question :
Does anyone know about making subplot in two forloops, then combine them into one graph?
And refer to Cedric's answer, what if my problem like this:
figure() ;
for plotId = 1 : 5
subplot(2, 2, plotId) ;
plot(x{plotId}, y{plotId}) ;
end
figure() ;
for plotId = 6 : n
subplot(2, 2, plotId) ;
plot(x{plotId+4}, y{plotId+4}) ;
end
I separate those two forloops because of i have different method for solving each case, and it can't be united together for some reason (Multisteps method)
How can i do that?
When i try that script above, my code shows many graphs. And i just want the result shows one graph Not many graphs, and this graph must contains for i=1:n which is from 2 forloops that united together (1:5 + 6:n).
Please comment below if it's not clear. Thanks

답변 (1개)

Walter Roberson
Walter Roberson 2019년 12월 18일
Yes, that is certainly possible. However you need to change the 2, 2 first two parameters to p, q where p times q >= n . Also, remove the second figure() call.
Question: is it true that you do not want to plot x{6}, x{7}, x{8}, x{9} ? You skip from x{5} to x{6+4} which is x{10}

카테고리

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

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by