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 Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by