Clear Filters
Clear Filters

How can I plot a figure with 5 subplots and save it and then move to the next figure containing 5 subplots and save it under an other name?

11 views (last 30 days)
Hy, I have a dataset of 100 columns (each columns represents one channel) 150000 rows.
Now I want to create 20 figures and each figure should show the data of 5 channels in subplots.
For example:
for i=1:5
h(i) = subplot(5,1,i);
plot(t,Ch0_99_OS1(:,i));
title(NewName(i));
ylabel('intensity [a. u.]');
xlabel('time [sec]');
ylim ([-1200 27000]);
end
Now I want to save the file as Ch1_5.png and start with the next figure containing the data from channel 6-10.
How can i do this?
Thanks

Accepted Answer

Bob Thompson
Bob Thompson on 2 May 2019
You can assign a figure number with the figure command.
You can save a figure with the savefig command.
Just put them both, or the savefig, into a for loop and you should be good.
for f = 1:20;
for i=1:5
h(i) = subplot(5,1,i);
plot(t,Ch0_99_OS1(:,i+(j-1)*5));
title(NewName(i));
ylabel('intensity [a. u.]');
xlabel('time [sec]');
ylim ([-1200 27000]);
end
savefig(['myfigure',num2str(f),'.png']);
end

More Answers (0)

Community Treasure Hunt

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

Start Hunting!