Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

displaying "half" of a 3d plot

3 views
Skip to first unread message

Peter Schreiber

unread,
Mar 11, 2010, 5:37:04 PM3/11/10
to
Hi guys,
I would like to display only half of a 3d plot to show some details of the functions.
More specificly, I want to make a diagonal cut through the 3d plot, and only display one half.
I could get it to work using plot3, but I really would need to represent a surface.

That's what I came up with so far:

[x,y]=meshgrid(linspace(-1,1,100));
t=triu(ones(size(x)),-1)&ones(size(x));
z=x.^2+y.^2;
plot3(x(t),y(t),z(t),'o')

Is there any chance to really represent the function z as a surface?

Best Regards,
Peter

Steven Lord

unread,
Mar 12, 2010, 11:10:28 AM3/12/10
to

"Peter Schreiber" <schreibe...@gmail.com> wrote in message
news:hnbrag$e9l$1...@fred.mathworks.com...


Use:

z(~t) = NaN;
surf(x, y, z);

instead of your PLOT call.

Actually, since I believe you can express your condition as a function of x
and y, you don't need to create t. An example that you can adjust to suit
your specific needs:

[x,y]=meshgrid(linspace(-1,1,100));
z=x.^2+y.^2;
z(x < y) = NaN;
surf(x, y, z)

--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


0 new messages