Search code examples
matlabmatlab-figuremeshsurf

Draw mesh/surf plot without certain point


I would like to draw a mesh plot. As the function goes, it always plots all the entries inside the input matrix. However, now I want a certain entry not to draw out, for example:

x = 1:3
y = 1:3
[X,Y]=meshgrid(x,y);
Z = [2,2,2;4,4,4;5,5,0];

where "0" is the entry I would not like to draw. After using mesh(X,Y,Z) or surf(X,Y,Z), it still shows that point with height = 0 enter image description here

Is there any way to hide that point? Thanks!


Solution

  • Replace the 0with inf:

    x = 1:3
    y = 1:3
    [X,Y]=meshgrid(x,y);
    Z = [2,2,2;4,4,4;5,5,inf];
    

    inf is typically ignored by drawing commands.