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

1 view (last 30 days)
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');

Answers (1)

Mathieu NOE
Mathieu NOE on 6 Sep 2021
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')

Community Treasure Hunt

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

Start Hunting!