do while in matlab

9 ビュー (過去 30 日間)
asim asrar
asim asrar 2019 年 11 月 2 日
回答済み: KALYAN ACHARJYA 2019 年 11 月 2 日
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 件のコメント
darova
darova 2019 年 11 月 2 日
Try continue instead of break
asim asrar
asim asrar 2019 年 11 月 2 日
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

サインインしてコメントする。

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 11 月 2 日
% 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?

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by