subplot with for loop after 10 new figure

5 views (last 30 days)
Hi,
I plot subplots with a for loop. After 10 subplots I want a new figure with the next 10 subplots an so on. At the end there shold be a number of figures each 10 subplots.
Thanks in advance.
Here my code:
for i=1:10
sgtitle('WSPL zeitlicher Verlauf Modell D Teil 1')
subplot(10,1,i)
hold on
p1=plot (col2_Z(:,i) , [col3_Z(:,i), col3_HQextrem(:,i), col3_HQ5000(:,i), col3_HQ10000(:,i)]);
title(['Zeit [h] ', num2str(i)])
grid on
leg=legend(p1,{'Geländehöhe','HQextrem','HQ5000', 'HQ10000'})
title(leg,'WSPL')
newcolors = {'#000000','#7E2F8E','#0000FF','#00FFFF'};
colororder(newcolors)
end

Accepted Answer

Chunru
Chunru on 4 May 2022
for i=1:100 % any number
if rem(i-1, 10) == 0
figure;
end
sgtitle('WSPL zeitlicher Verlauf Modell D Teil 1')
subplot(10, 1, rem(i-1, 10)+1);
hold on
p1=plot (col2_Z(:,i) , [col3_Z(:,i), col3_HQextrem(:,i), col3_HQ5000(:,i), col3_HQ10000(:,i)]);
title(['Zeit [h] ', num2str(i)])
grid on
leg=legend(p1,{'Geländehöhe','HQextrem','HQ5000', 'HQ10000'})
title(leg,'WSPL')
newcolors = {'#000000','#7E2F8E','#0000FF','#00FFFF'};
colororder(newcolors)
end

More Answers (0)

Community Treasure Hunt

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

Start Hunting!