Save figure in a subplot loop
이전 댓글 표시
Hi,
i have this code an want to save the figure as png and fig , if there are 5 subplots.
The name should be then for example: hours_5, hours_10....
for i=1:100
if rem(i-1, 5) == 0
figure;
end
sgtitle('WSPL zeitlicher Verlauf Modell D Teil 2')
a(i)=subplot(5, 1, rem(i-1, 5)+1)
hold on;
[maxHQextrem,indexHQextrem]=max(Hoehe_HQextrem(:,i)- Hoehe_Z(:,i));
[maxHQ5000,indexHQ5000]=max(Hoehe_HQ5000(:,i)- Hoehe_Z(:,i));
[maxHQ10000,indexHQ10000]=max(Hoehe_HQ10000(:,i)- Hoehe_Z(:,i));
str = ['Maximaler Überlauf [m]: HQextrem ',num2str(maxHQextrem),' HQ5000 ',num2str(maxHQ5000),' HQ10000 ',num2str(maxHQ10000)];
b(i) = annotation('textbox','String',str,'Position',a(i).Position,'Vert','bottom','FitBoxToText','on');
hold on
% annotation('textbox', 'String',str)
p1=plot (Distanz_Z(:,i) , [Hoehe_Z(:,i), Hoehe_HQextrem(:,i), Hoehe_HQ5000(:,i), Hoehe_HQ10000(:,i)]);
title(['Zeit [h] ', num2str(i)])
grid on
xline(indexHQextrem,'-','Maximum','LabelOrientation','horizontal')
xline(indexHQ5000)
xline(indexHQ10000)
leg=legend(p1,{'Geländehöhe','HQextrem','HQ5000', 'HQ10000'})
title(leg,'WSPL')
newcolors = {'#000000','#7E2F8E','#0000FF','#00FFFF'};
colororder(newcolors)
xlabel('FKM [km]');
ylabel('Höhe über NN [m]')
xticks([738.98 1734.44 2744.03 3687.56 4722.17 5762.52 6831.7 7228.84])
xticklabels({'118','117','116','115', '114', '113', '112', '111'})
end
thanks in advance
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Printing and Saving에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!