MATLAB: How can I combine several file.fig together

combine .fig files

I have several files which their formats are.fig (actually they are graphs), I need to combine them together for comparison.
could you please help me which function I can use?

Best Answer

It's unclear whether you want to combine each line into the same axes or if you want to combine each axes into the same figure as a set of subplots.
This demo combines the lines from all axes into 1 axes and changes their colors and legend names. The axes will have the same properties as the first copied axes.
Assumptions:
  1. Each figure contains only 1 axes
  2. Each axes contains only 1 graphics object (ie, your blue lines).
If these assumptions aren't met slight adjustments will be needed to access the desired handles.
% List figures
figureList = {'103_RU.fig','118_RU.fig'};
% List new line colors
lineCol = jet(numel(figureList));
% Open each figure and copy content
for i = 1:numel(figureList)
% Open fig-i
fighand = open(figureList{i});
% Get axis handle (assumption: only 1 axes in figure)
axHand = findobj(fighand, 'Type', 'Axes');
% on first iteration only, create new figure and
% copy the entire axis from fig-i
if i==1
fh = figure();
newAxes = copyobj(axHand, fh);
hold(newAxes, 'on')
title(newAxes,'Combined RU')
h = newAxes.Children;
else
% copy content of axes
h = copyobj(axHand.Children, newAxes);
end
% Set line color and displayname
h.Color = lineCol(i,:);
h.DisplayName = axHand.Title.String;
% Close fig-i
close(fighand)
end
% Ceate legend
legend(newAxes, 'Interpreter', 'None')