Plot3 interpolation 3D plot
Ältere Kommentare anzeigen
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) ;
----------------------------------------------------------------------------------------------------------------------
Antworten (1)
KSSV
am 23 Jun. 2021
0 Stimmen
If NaN's are present, it will effetct the interpolation. Fill the NaN's using fillmissing.
1 Kommentar
Amila Wickramasinghe
am 23 Jun. 2021
Kategorien
Mehr zu Interpolation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!