Hello everybody,
For my homework, I have to plot 5 different 3D figures that I have already created into a same figure. Figures have already title and axis info. I just need to plot them on a same figure. Code I used is below. When I try to run it, I couldn't get the result. Any help? Thanks
clear all
close all
clc
filename1='first.fig';
filename2='second.fig';
filename3='third.fig';
filename4='fourth.fig';
filename5='fifth.fig';
ax0=figure(1);
h1 = openfig(first,'reuse');
ax1 = gca;
hold on
s1=subplot(5,1,1);
h2 = openfig(second,'reuse');
ax2 = gca;
hold on
s2=subplot(5,1,2);
h3 = openfig(third,'reuse');
ax3 = gca;
hold on
s3=subplot(5,1,3);
h4 = openfig(fourth,'reuse');
ax4 = gca;
hold on
s4=subplot(5,1,4);
h5 = openfig(fifth,'reuse');
ax5 = gca;
hold on
s5=subplot(5,1,5);
figure(1)
fig1 = get(ax1,'children'); %get handle to all the children in the figure
fig2 = get(ax2,'children');
fig3 = get(ax3,'children');
fig4 = get(ax4,'children');
fig5 = get(ax5,'children');
copyobj(fig1,s1); %copy children to new parent axes i.e. the subplot axes
copyobj(fig2,s2);
copyobj(fig3,s3);
copyobj(fig4,s4);
copyobj(fig5,s5);
saveas(ax0,'Result','fig');
print -dpng -r300 Result.png
For my homework, I have to plot 5 different 3D figures that I have already created into a same figure. Figures have already title and axis info. I just need to plot them on a same figure. Code I used is below. When I try to run it, I couldn't get the result. Any help? Thanks
clear all
close all
clc
filename1='first.fig';
filename2='second.fig';
filename3='third.fig';
filename4='fourth.fig';
filename5='fifth.fig';
ax0=figure(1);
h1 = openfig(first,'reuse');
ax1 = gca;
hold on
s1=subplot(5,1,1);
h2 = openfig(second,'reuse');
ax2 = gca;
hold on
s2=subplot(5,1,2);
h3 = openfig(third,'reuse');
ax3 = gca;
hold on
s3=subplot(5,1,3);
h4 = openfig(fourth,'reuse');
ax4 = gca;
hold on
s4=subplot(5,1,4);
h5 = openfig(fifth,'reuse');
ax5 = gca;
hold on
s5=subplot(5,1,5);
figure(1)
fig1 = get(ax1,'children'); %get handle to all the children in the figure
fig2 = get(ax2,'children');
fig3 = get(ax3,'children');
fig4 = get(ax4,'children');
fig5 = get(ax5,'children');
copyobj(fig1,s1); %copy children to new parent axes i.e. the subplot axes
copyobj(fig2,s2);
copyobj(fig3,s3);
copyobj(fig4,s4);
copyobj(fig5,s5);
saveas(ax0,'Result','fig');
print -dpng -r300 Result.png