How to smoothly interpolate between distant points in 2D matrix?
Ältere Kommentare anzeigen
Hey guys,
I have a matrix such as A = [0 0 0 0 0 0;0 5 7 0 9 0;0 0 0 0 0 0;0 0 0 0 0 0;0 0 0 0 0 0;0 0 5 0 0 0;0 3 0 0 6 0;1 0 0 0 0 0]; as I only have some measurements in the area 8x6, points without measurements are zero.
Now I want to interpolate between the points where I have data (>0) using the following:
%if true
[X,Y] = meshgrid(1:1:6,1:1:8);
[Xq,Yq] = meshgrid(1:0.1:6,1:0.1:8);
Vq = interp2(X,Y,A,Xq,Yq);
surf(Xq,Yq,Vq)
%end
This is the product:

The question is, how can I only interpolate between the points with values >0 ("connect the peaks"? If I try to set all zeros as NaN the result is even worse...
Thanks a lot for your help!
Valle
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Interpolation of 2-D Selections in 3-D Grids 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!
