f = figure;
surf(peaks)
hgsave(f,'one.fig')
close(f)
f = figure;
t = 0:pi/50:10*pi;
plot(t, sin(t));
legend(gca, 'sinx')
hgsave(f,'two.fig')
close(f)
f = figure;
a1 = subplot(2,1,1);
a2 = subplot(2,1,2);
f_c = openfig('one.fig');
axes_to_be_copied = findobj(f_c,'type','axes');
chilred_to_be_copied = get(axes_to_be_copied,'children');
[az,el] = view;
copyobj(chilred_to_be_copied,a1);
set(a1,'Xlim',get(axes_to_be_copied,'XLim'))
set(a1,'Ylim',get(axes_to_be_copied,'YLim'))
set(a1,'Zlim',get(axes_to_be_copied,'ZLim'))
view(a1,[az,el])
close(f_c);
f_c = openfig('two.fig');
axes_to_be_copied = findobj(f_c,'type','axes', '-not', 'tag', 'legend');
legend_to_be_copied = findobj(f_c,'type','axes', 'tag', 'legend');
chilred_to_be_copied = get(axes_to_be_copied,'children');
[az,el] = view;
copyobj(chilred_to_be_copied,a2);
if isfloat(legend_to_be_copied)
copyobj(legend_to_be_copied, f);
end
set(a2,'Xlim',get(axes_to_be_copied,'XLim'))
set(a2,'Ylim',get(axes_to_be_copied,'YLim'))
set(a2,'Zlim',get(axes_to_be_copied,'ZLim'))
view(a2,[az,el])
close(f_c);
Best Answer