How to plot a constant function in 3D?

3 次查看(过去 30 天)
Anna
Anna 2012-5-7
Hi guys,
I am a newbie. I want to plot:
f(x,y)={1/4 if -1 <= x <= 1 and -1 <= y <= -2x+1; 0 otherwise on x,y : [-2,2]
I have tried with plot3 and mesh but I failed. Any suggestions? Thanks.

回答(1 个)

Walter Roberson
Walter Roberson 2012-5-7
[X, Y] = ndgrid(linspace(-2,2,100));
F = zeros(size(X));
F(X >= -1 & SOMETHING_GOES_HERE) = 1/4;
surf(X, Y, F);

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by