Saving multiple plots into one folder with the specified figure name in code to jpg form

1 回表示 (過去 30 日間)
Harish M Y
Harish M Y 2021 年 9 月 5 日
回答済み: Mathieu NOE 2021 年 9 月 6 日
Hi,
I am trying to save all the plots generated from the code to the user specified folder in the form of jpg. Please help me to get the thing done.
I am using the below code
figure('Name','Pressure In','NumberTitle','off')
x = out.Pin(:,1);
y = out.Pin(:,2);
plot(x,y);
grid on
title('Pump Inlet Pressure');
xlabel('Time');
ylabel('Pressure');
figure('Name','Pressure Out','NumberTitle','off')
x1 = out.Pout(:,1);
y1 = out.Pout(:,2);
plot(x1,y1);
grid on
title('Pump Outet Pressure');
xlabel('Time');
ylabel('Pressure');
figure('Name','Heat Generation','NumberTitle','off')
hold on
x2 = out.Q2(:,1);
y2 = out.Q2(:,2:end);
plot(x2,y2);
grid on
title('Heat Generation');
xlabel('Time');
ylabel('Heat Flow');
legend('Battery Module 1','Battery Module 2','Battery Module 3','Battery Module 4','Battery Module 5','Battery Module 6','Battery Module 7','Battery Module 8','Battery Module 9','Battery Module 10','Battery Module 11','Battery Module 12','Battery Module 13','Battery Module 14');
figure('Name','Total Heat','NumberTitle','off')
hold on
x3 = out.Q_25_100(:,1);
y3 = out.Q_25_100(:,2);
plot(x3,y3);
grid on
title('Heat Generation');
xlabel('Time');
ylabel('Heat Flow');
legend('Summed Heat Flow');
figure('Name','SOC','NumberTitle','off')
x4 = out.SOC_25_100(:,1);
y4 = out.SOC_25_100(:,2);
plot(x4,y4);
grid on
title('Battery State of Charge');
xlabel('Time');
ylabel('SOC');
legend('SOC');
figure('Name','Battery Temperatures','NumberTitle','off')
hold on
x2 = out.T_25_100(:,1);
y2 = out.T_25_100(:,2:end);
plot(x2,y2);
grid on
title('Battery Module Temperatures');
xlabel('Time');
ylabel('Temperature');
legend('Battery Module 1','Battery Module 2','Battery Module 3','Battery Module 4','Battery Module 5','Battery Module 6','Battery Module 7','Battery Module 8','Battery Module 9','Battery Module 10','Battery Module 11','Battery Module 12','Battery Module 13','Battery Module 14');
figure('Name','Chiller Temperature In','NumberTitle','off')
hold on
x2 = out.Tin_25_100(:,1);
y2 = out.Tin_25_100(:,2:end);
plot(x2,y2);
grid on
title('Chiller Inlet Temperature');
xlabel('Time');
ylabel('Temperature');
legend('Temperature');
figure('Name','Chiller Temprature Out','NumberTitle','off')
hold on
x2 = out.Tout_25_100(:,1);
y2 = out.Tout_25_100(:,2:end);
plot(x2,y2);
grid on
title('Chiller Outlet Temperature');
xlabel('Time');
ylabel('Temperature');
legend('Temperature');

回答 (1 件)

Mathieu NOE
Mathieu NOE 2021 年 9 月 6 日
hello
why not simply add this line of code after each figure :
adjust the resolution to your needs (here 140 DPI)
print('-djpeg','-r140','My Plot Name here')

カテゴリ

Help Center および File ExchangeBattery Pack Modeling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by