Export multiple figures in a directory

1 view (last 30 days)
Hi, I have this piece of code:
clear all;
close all;
x=(1:1:50);
y=x.^2;
z=x.^3;
t=-10*z;
aaa=[y; z; t];
for i=1:size(aaa,1);
figure(i);
plot(x,aaa(i,:));
xlabel('Time [s]','FontSize',15);
if i==1
axis([0 30 0 1000]);
ylabel('Temp[K]','FontSize',15);
else if i==2
axis([0 35 0 60000]);
ylabel('Heat[W]','FontSize',15);
else if i==3
axis([0 40 -60000 0]);
ylabel('Flow[Kg/s]','FontSize',15);
end
end
saveas(gcf,'H:\MATLAB\PI610_fig\APRM_fig022.png');
end
end
How can I export multiple figures having a predefined path, cutting also the blak space(Here Aprmfig022.png is overwritten)? Thank you.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 9 Jul 2015
close all;
x=(1:1:50);
y=x.^2;
z=x.^3;
t=-10*z;
aaa=[y; z; t];
for i=1:size(aaa,1);
figure(i);
plot(x,aaa(i,:));
xlabel('Time [s]','FontSize',15);
if i==1
axis([0 30 0 1000]);
ylabel('Temp[K]','FontSize',15);
elseif i==2
axis([0 35 0 60000]);
ylabel('Heat[W]','FontSize',15);
elseif i==3
axis([0 40 -60000 0]);
ylabel('Flow[Kg/s]','FontSize',15);
end
saveas(gcf,sprintf('H:\MATLAB\PI610_fig\APRM_fig%d.png',i))
end

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!