MATLAB: Combine fig files into 1 figure

.fig filescombinecombine figuresfiguresubplot

Hi,
I have 3 fig files and want to combine them into 1 figure (see picture uploaded)
I have tried with subplots but did not work.
This is my code, and my fig files are also attached:
figure
subplot(3,1,1)
openfig('SARIMA_forecast.fig'); % open figure
subplot(3,1,2)
openfig('VAR_forecast.fig'); % open figure
subplot(3,1,3)
openfig('VECM_forecast.fig'); % open figure

Best Answer

Run this code
fig(1) = openfig('SARIMA_forecast.fig'); % open figure


fig(2) = openfig('VAR_forecast.fig'); % open figure
fig(3) = openfig('VECM_forecast.fig'); % open figure
new_fig = figure;
ax_new = gobjects(size(fig));
for i=1:3
ax = subplot(3,1,i);
ax_old = findobj(fig(i), 'type', 'axes');
ax_new(i) = copyobj(ax_old, new_fig);
ax_new(i).YLimMode = 'manual';
ax_new(i).Position = ax.Position;
ax_new(i).Position(4) = ax_new(i).Position(4)-0.02;
delete(ax);
end