How can I combine two existing figures in one?

조회 수: 3 (최근 30일)
Nilou
Nilou 2017년 9월 22일
댓글: Nilou 2017년 9월 23일
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?
  댓글 수: 2
Akira Agata
Akira Agata 2017년 9월 22일
Do you mean you want to make 'subplot' figure ?, or want to plot two surfaces in a same axes ?
Nilou
Nilou 2017년 9월 22일
Akira Agata, Thank you for your comment! Basically, this is what I have:
figure
f=fit( [x, y], z, 'poly23' );
plot(f, [x, y], z);xlabel('x');ylabel('y');zlabel('response');
figure
f=fit( [x, y], z, 'poly23' );
plot(f, [x, y],z,'style','contour'); xlabel('x');ylabel('y');zlabel('response');
now I want to have these two in a same axes.(and I'd like to mention that I was not able to use fsurf function ) Thanks.

댓글을 달려면 로그인하십시오.

채택된 답변

Akira Agata
Akira Agata 2017년 9월 22일
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');
  댓글 수: 1
Nilou
Nilou 2017년 9월 23일
Akira Agata Thank you very much. it is perfect.
just another question, how can I shift the second plot vertically? I need two plots in the same axes and also with different vertical position.
Thanks again.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by