MATLAB: How to combine two existing figures in one

combinefiguresfiguremergefigures

Hello all, I have two figures with a surface plotted in each one.The figures have the same axes, titles,…. How can I have these two together in one figure?

Best Answer

Nilou-san,
Thanks for giving me the detail. OK, the following is sample code for plotting your two plots in the same axes. I hope this will be helpful for you!
rng('default'); % for reproducibility
x = sort(rand(10,1));
y = sort(rand(10,1));
z = sort(rand(10,1));
f1 = fit( [x, y], z, 'poly23' );
f2 = fit( [x, y], z, 'poly23' );
figure
plot(f1, [x, y], z);
hold on;
plot(f2, [x, y],z,'style','contour');
xlabel('x');
ylabel('y');
zlabel('response');