How can I draw 2 surfaces in one graph?

조회 수: 1 (최근 30일)
Vijal Gala
Vijal Gala 2017년 6월 16일
편집: KSSV 2017년 6월 16일
Hi,
I am trying to create a 3d graph with 2 surfaces as I have 2 sets of 3d data. When i run the programme, the graphs are generated seperately. Please help. Below is the code I used:
function [fitresult, gof] = graph1(a, b, c, d)
[xData, yData, zData] = prepareSurfaceData( a, b, c );
ft = fittype( 'biharmonicinterp' );
opts = fitoptions( ft );
opts.Normalize = 'on';
[fitresult{1}, gof(1)] = fit( [xData, yData], zData, ft, opts );
figure( 'Name', 'surface1' );
h = plot( fitresult{1}, [xData, yData], zData );
xlabel( 'a' );
ylabel( 'b' );
zlabel( 'x' );
grid on
hold on;
[xData, yData, zData] = prepareSurfaceData( a, b, d ),
ft = 'linearinterp';
opts = fitoptions( ft );
opts.Normalize = 'on';
[fitresult{2}, gof(1)] = fit( [xData, yData], zData, ft, opts );
figure( 'Name', 'surface2' );
h = plot( fitresult{2}, [xData, yData], zData );
xlabel( 'a' );
ylabel( 'b' );
zlabel( 'x' );
grid on
Thank you.
  댓글 수: 3
Tina
Tina 2017년 6월 16일
Adam is right. If you use "figure(...)" again after "hold on;", it will ignore the "hold on" and generate a new plot.
Vijal Gala
Vijal Gala 2017년 6월 16일
Thank you. I was able to get it right.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by