save multiple plots in user specified folder in jpg form

1 visualización (últimos 30 días)
Harish M Y
Harish M Y el 6 de Sept. de 2021
Comentada: KSSV el 6 de Sept. de 2021
Hi,
I am plotting multiple plots in single code and I want to save all the plots into user specified folder in jog form.
Please help me with this.
The code to generate plots is shown below
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');

Respuestas (1)

KSSV
KSSV el 6 de Sept. de 2021
Read about saveas. After the plot you can use:
saveas(gcf,'Figure1.jpg')
  2 comentarios
Harish M Y
Harish M Y el 6 de Sept. de 2021
Thanks, this works for one figure.
I want all the figures to be converted into jpg format and save in user specified folder using uigetdir() with the figure names i mentioned in the code automatically.
KSSV
KSSV el 6 de Sept. de 2021
If you are plotting in a figure:
for i = 1:10
% plot here
imagename = [num2str(i),'.png'] ;
saveas(gcf,imageName)
end

Iniciar sesión para comentar.

Categorías

Más información sobre Propulsion and Power Systems en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by