How to plot a constant function in 3D?

3 vues (au cours des 30 derniers jours)
Anna
Anna le 7 Mai 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.

Réponses (1)

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

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by