matlab - Displaying surface with non-rectangular boundary -
refer attached image. want display image in matlab using function surf()
. however, want display region of actual object without background (the pale-green region surrounding actual object has 0 value). how that? tried replacing outer region 0
nan
, setting values in height map nonzero value, still error message:
subscript indices must either real positive integers or logicals.
so how can display surface has non-rectangular boundary?
setting values nan
should do. here's example:
[x, y] = ndgrid(linspace(-1,1,500)); z = cos(2*pi*(x+y)*2); z(x.^2+y.^2>1) = nan; %// remove values outside unit circle surf(x,y,z,'edgecolor','none') colorbar view(2) axis equal
Comments
Post a Comment