surf command doesn't plot the value next to NaNs values
Afficher commentaires plus anciens
Hi! I don't understand why the surf command doesn't plot the value next to NaNs values in the matrix M_array. For example the second pixel of the first row is 124, but it doesn't appear.
a=[40:0.05:41];
b=[-40:-0.05:-41];
[c,d] = meshgrid(a,b);
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 14 Oct 2021
How about if you just interpolate over the nans with the regionfill() function?
load M_array
% Fill nan holes in M_array.
nanMap = isnan(M_array);
M_arrayRepaired = regionfill(M_array, nanMap)
% Rest of code:
a=[40:0.05:41];
b=[-40:-0.05:-41];
[c,d] = meshgrid(a,b);
surf(c,d,ones(size(M_arrayRepaired)),M_arrayRepaired)
view(2)
colormap gray
colorbar
3 commentaires
Valeria Leto
le 14 Oct 2021
Image Analyst
le 14 Oct 2021
@Valeria Leto, I'm not Dave. I was the one who suggested "repairing" your array by getting rid of the nan holes. (If you like that idea, you can "Vote" for my Answer.)
But beware if you use surf() the "tiles" are not the values of your array. Look at Dave's demo. A 3-by-4 array shows up with 2-by-3 colored tiles, not 3-by-4. Just wanted to make sure you knew about this quirk regarding the surf() and pcolor() functions.
Valeria Leto
le 16 Oct 2021
Catégories
En savoir plus sur Lighting, Transparency, and Shading dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

