clear Z=[-4:1:2];H=[0:1:4]; [xx,yy]=meshgrid(Z,H); zz=0.4166+0.0456.*yy-0.2343.*xx; if zz>=1 then zz=1 end if zz<=0 then zz=0 figure surf(xx,yy,zz) I want the value staying at (0,1), how to make this happen? and why this program doesn't work

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 30일

0 개 추천

clear
Z=[-4:1:2];
H=[0:1:4];
[xx,yy]=meshgrid(Z,H);
zz=0.4166+0.0456.*yy-0.2343.*xx;
zz(zz>1)=1
zz(zz<0)=0
figure
surf(xx,yy,zz)

댓글 수: 2

huang
huang 2013년 11월 30일
thanks you! and how to make 'if' sentence work in this context?
clear
Z=[-4:1:2];
H=[0:1:4];
[xx,yy]=meshgrid(Z,H);
zz=0.4166+0.0456.*yy-0.2343.*xx;
for k=1:numel(zz)
if zz(k)>1
zz(k)=1
elseif zz(k)<0
zz(k)=0
end
end
figure
surf(xx,yy,zz)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

TAMILAN
TAMILAN 2024년 7월 3일

0 개 추천

clear
Z=[-4:1:2];
H=[0:1:4];
[xx,yy]=meshgrid(Z,H);
zz=0.4166+0.0456.*yy-0.2343.*xx;
for k=1:numel(zz)
if zz(k)>1
zz(k)=1
elseif zz(k)<0
zz(k)=0
end
end
figure
surf(xx,yy,zz)

카테고리

도움말 센터File Exchange에서 Instrument Connection and Communication에 대해 자세히 알아보기

태그

질문:

2013년 11월 30일

답변:

2024년 7월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by