Plot3 interpolation 3D plot

조회 수: 3 (최근 30일)
Amila Wickramasinghe
Amila Wickramasinghe 2021년 6월 23일
댓글: Amila Wickramasinghe 2021년 6월 23일
Hello,
I want to create a 3D plot with following x, y, z data and I can do that. There are some z data points which do not have a values (NaN). Now I want to make a regular grid and interpolate the scattered data over the grid. Howeverm it doesn't show up the interpolated grid. Is this a problem because of these NaN points? If so, how can I solve this?
Thanks in advance!
My code:
-------------------------------------------------------------------------------------------------------
x=[-1.45 -1 -0.85 -0.55 0 0.55 0.85 1 1.45];
y=[1.45 1.25 1 0.55 0 -0.55 -1 -1.25 -1.45];
z=[NaN NaN NaN NaN 0.339 NaN NaN NaN NaN
NaN NaN 0.346 NaN NaN NaN 0.346 NaN NaN
NaN NaN NaN NaN 2.088 NaN NaN NaN NaN
NaN NaN NaN NaN 1.409 NaN NaN NaN NaN
1.7065 1.8016 NaN 3.0193 NaN 3.125 NaN 2.151 1.402
NaN NaN NaN NaN 1.72 NaN NaN NaN NaN
NaN NaN NaN NaN 1.624 NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN 0.847 NaN NaN NaN NaN ];
plot3(x,y,z,'O')
grid on
[xq,yq] = meshgrid(-2:0.1:2, -2:0.1:2);
vq = griddata(x,y,z,xq,yq);
mesh(xq,yq,vq)
hp = stem3(x,y,z) ;
----------------------------------------------------------------------------------------------------------------------

답변 (1개)

KSSV
KSSV 2021년 6월 23일
If NaN's are present, it will effetct the interpolation. Fill the NaN's using fillmissing.
  댓글 수: 1
Amila Wickramasinghe
Amila Wickramasinghe 2021년 6월 23일
Thank you very much, KSSV!

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

카테고리

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