Plot3 interpolation 3D plot
显示 更早的评论
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
2021-6-23
0 个投票
If NaN's are present, it will effetct the interpolation. Fill the NaN's using fillmissing.
类别
在 帮助中心 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!