MATLAB: Merge two figs to one fig

merge

Dear customer service support,
I hope my email finds you well
I have two figs and I want to merge it to one fig. could you please help me to do that?
Please response me as soon as possible because I need them sooner as you can.
Many thanks in advance and I will apperciate your help
Best regrads,
Nouf

Best Answer

Since each point is plotted as a separate Line object (5342 in ‘1.fig’ and 3608 in ‘2.fig’), this code is slow, since it has to regenerate that, and since I have no idea what the separate markers or marker colours mean, I decided not to combine them by those characteristics into different vectors. It is likely much easier with the original data rather than having to extract them from .fig files. Plotting the combined figure, I left the colours and markers as they were in the original figures.
Try this:
F1 = openfig('1.fig');
L1 = findobj(gca,'Type','line');
for k = 1:numel(L1)
X1(k) = L1(k).XData;
Y1(k) = L1(k).YData;
C1{k} = L1(k).Color;
M1{k} = L1(k).Marker;
end
F2 = openfig('2.fig');
L2 = findobj(gca,'Type','line');
for k = 1:numel(L2)
X2(k) = L2(k).XData;
Y2(k) = L2(k).YData;
C2{k} = L2(k).Color;
M2{k} = L2(k).Marker;
end
figure
hold on
for k = 1:numel(L1)
plot(X1(k), Y1(k), 'Color',C1{k}, 'Marker',M1{k})
end
for k = 1:numel(L2)
plot(X2(k), Y2(k), 'Color',C2{k}, 'Marker',M2{k})
end
hold off
xlabel('Time')
ylabel('Out_1')
title('Combined')
axl = axis;
axis([-100 axl(2) -1E-11 axl(4)])
Pos = get(gcf,'Position')
set(gcf,'Position',Pos+[0 0 750 250])
Have fun!
.