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