How to plot a constant function in 3D?

4 views (last 30 days)
Anna
Anna on 7 May 2012
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.

Answers (1)

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

Categories

Find more on Line Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!