do while in matlab

10 visualizaciones (últimos 30 días)
asim asrar
asim asrar el 2 de Nov. de 2019
Respondida: KALYAN ACHARJYA el 2 de Nov. de 2019
i have a condition for my code
stage A
A1= Zmed-Zmin
A2=Zmed-Zmax
if A1 >0 and A2 <0 go to stage B
else w=w+1
if w < wmax ,repeat stage A
else output zmed
stage B
B1= Zxy -Zmin
B2 = Zxy - Zmax
if B1>0 and B2<0 Output Zxy
else output Zmed
can someone help me in for this code
i tried writing it as
while 1
A1=Zmed-Zmin
A2=Zmed-Zmax
if A1>0 && A2<0 break
else w=w+1;
if w <= Wmax continue
else
B(i,j)=Zmed;
end
end
B1=Zxy-Zmin
B2=Zxy-Zmin
if B1>0 && B2<0
B(i,j)=Zxy;
else
B(i,j)=Zmed;
end
but its not working
  2 comentarios
darova
darova el 2 de Nov. de 2019
Try continue instead of break
asim asrar
asim asrar el 2 de Nov. de 2019
but i have the condition that if A>0 and A2<0
then i have to come out of the loop
so i have to use brak for that ,
my question is how to code this conditions -
stage A
A1= Zmed-Zmin
A2=Zmed-Zmax
if A1 >0 and A2 <0 go to stage B
else w=w+1
if w < wmax ,repeat stage A
else output zmed
stage B
B1= Zxy -Zmin
B2 = Zxy - Zmax
if B1>0 and B2<0 Output Zxy
else output Zmed

Iniciar sesión para comentar.

Respuesta aceptada

KALYAN ACHARJYA
KALYAN ACHARJYA el 2 de Nov. de 2019
% Stage A
while 1
A1=Zmed-Zmin
A2=Zmed-Zmax
if A1>0 && A2<0
break;
else
w=w+1;
if w<=Wmax
continue;
else
B(i,j)=Zmed % Assumed that i & j are already defined
break; % Assumed that after this step pass to stage B, as not defined in the question
end
end
end
% Stage B
B1=Zxy-Zmin
B2=Zxy-Zmin
if B1>0 && B2<0
B(i,j)=Zxy;
else
B(i,j)=Zmed;
end
Please try, any issue let me know?

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos


Versión

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by