Plot3 interpolation 3D plot

8 vues (au cours des 30 derniers jours)
Amila Wickramasinghe
Amila Wickramasinghe le 23 Juin 2021
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) ;
----------------------------------------------------------------------------------------------------------------------

Réponses (1)

KSSV
KSSV le 23 Juin 2021
If NaN's are present, it will effetct the interpolation. Fill the NaN's using fillmissing.
  1 commentaire
Amila Wickramasinghe
Amila Wickramasinghe le 23 Juin 2021
Thank you very much, KSSV!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by