How to select value

21 visualizaciones (últimos 30 días)
huang
huang el 30 de Nov. de 2013
Respondida: TAMILAN el 3 de Jul. de 2024
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

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 30 de Nov. de 2013
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 comentarios
huang
huang el 30 de Nov. de 2013
thanks you! and how to make 'if' sentence work in this context?
Azzi Abdelmalek
Azzi Abdelmalek el 30 de Nov. de 2013
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)

Iniciar sesión para comentar.

Más respuestas (1)

TAMILAN
TAMILAN el 3 de Jul. de 2024
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)

Categorías

Más información sobre Instrument Connection and Communication en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by