Repeat While loop with the final result (Matlab)

1 回表示 (過去 30 日間)
Afluo Raoual
Afluo Raoual 2021 年 3 月 24 日
編集済み: Afluo Raoual 2021 年 5 月 21 日
Dear members
I have a while loop
I want to modify the program in order when L in not equal to 0, the while loop must repeat the sum of L not of S
It means, for the first time I want the program to run as it is here (with S firstly). But when L is different to 0, when he do n=n+1, I want it to make
while (sum(sum(L))~=0)
f=sum(H(L==1,:),1);
and continue like this

回答 (1 件)

DGM
DGM 2021 年 3 月 24 日
編集済み: DGM 2021 年 3 月 24 日
For the future, please post code in a formatted code block. Don't post pictures of code. Nobody can run a picture of code. They have to sit there and manually retype the whole thing, often unintentionally omitting or adding typos.
If I understand you correctly, you're trying to change the variable that's controlling the loop exit. How about something like this?
variableundertest=S;
while sum(variableundertest(:))~=0
f=sum(H(variableundertest==1,:),1);
m=max(f);
i=find(f==m);
w=mod(i+1,2);
a=V;
a(i)=w;
L=mod(H*a',2);
if L==0
break;
else
n=n+1;
variableundertest=L;
end
end
I have no idea what this code is intended to do, but bear in mind that this would now mean that variableundertest is recalculated on every pass through the loop.
  2 件のコメント
DGM
DGM 2021 年 3 月 24 日
What is this code supposed to be doing conceptually? What does S represent? What does L represent?
DGM
DGM 2021 年 3 月 24 日
What sort of encoding/checking algorithm is this?

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by