Multiple figure in matlab

I created 4 different figures and i load it to a Matlab (4 figures in one page).Is it possible to export this page to png format ? (i need 4 graph per page)
Who is Participating?
yuk99Connect With a Mentor Commented:
Are you still interested in answer? Do you need automated solution in MATLAB?

The main problems with SUBPLOT are the following:
1. If you have multiple axes on even one of your figures. They will have to managed separately on subplot context, since subplot function actually returns only one axis. Sometime it can be hard.
2. Colormap has to be the same for all figures.
3. Large gaps between figures.

One way to avoid it:
1) save individual figures as PNG files
2) show all the images on one figure
3) print the figure to PNG

Here is the code after you save the individual figures:
ax(1) = axes('units','normalized','position',[0 0.5 0.5 0.5]);
ax(2) = axes('units','normalized','position',[0.5 0.5 0.5 0.5]);
ax(3) = axes('units','normalized','position',[0 0 0.5 0.5]);
ax(4) = axes('units','normalized','position',[0.5 0 0.5 0.5]);
print -dpng -r600 4figures.png

Open in new window

You need to set a good resolution in print command or appropriate figure size with set(gcf,'units','pixels','position',[0 0 width height]) before print.
IMSHOW requires Image Processing Toolbox. Can be substituted with IMAGE or IMAGESC, but need some additional steps.

If all your figures have the same size, here is the easier solution:
x = cell(2);
x{1,1} = imread('fig1.png');
x{1,2} = imread('fig2.png');
x{2,1} = imread('fig3.png');
x{2,2} = imread('fig4.png');
y = cell2mat(x); % will return an error if figures  size is different

Open in new window

Tom3333Author Commented:
No respond yet??
One option is to use subplot function while generating the figures as individual axes;

% code for figure 1
% ...
% code for figure 2
% ...
% code for figure 3
% ...
% code for figure 4
% ...

Open in new window

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

There are many File Exchange submissions related to your question. Some are just a better versions of SUBPLOT (used while creating the figures).

Others can combine separately generated figures into one figure.

Another one is SubplotPPT to save multiple figures to a single Powerpoint slide:
You can then arrange it as you want and save as PNG.
Tom3333Author Commented:
without  the use of subplot  (just to have 4 figure in one page) is it possible to export it?
No, you can export only one figure per page. If you want to put multiple figure on one page, you have to put them into one figure as axes. You can use SUBPLOT or arrange the axes manually with 'Position' property. Other alternatives I put above.

Please describe your problem in more details. How do you generate the figures? Why don't you like the SUBPLOT option?

You can also save multiple figures into one PDF or multipage TIF file, but they will be one figure per page. I think it's not what you want.
Kenneth BrownResearch AssociateCommented:
You can sort of cheat by using printscreen button to save to the clipboard a bitmap of the screen image while youve got any plot or subplot displayed, then manipulate these and save in png format using your graphics editor of choice, eg PSP etc.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.