フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Return back to the main function after while loop

1 回表示 (過去 30 日間)
fyza affandi
fyza affandi 2018 年 12 月 27 日
閉鎖済み: fyza affandi 2018 年 12 月 27 日
I have this code
table = [ 0 2 2 2 ; 1 0 0 2; 1 0 1 2; 1 1 0 0; 1 1 0 1];
code =[ 0 0 1 1 0 1 1 1 0 0 1 1 1 0 0 0];
n=1;result=[];loop=0;m=1;
while n <=16
[x,y]=find(table(:,1)==code(n)); %MAIN%
if length(x)==1 % option 1 %
result=[result,x];
n=n+1;
if length(x)>1 % option 2 %
while length(x)>1
[x,y]= find (code(n)== table(:,m));
n=n+1;
m=m+1;
end
result=[result,x];
end
end
end
How can I return to the %MAIN% after finish with % option 2 % ? Is there something missing?
The answer I got is
result = 1 1 5
It seems that after % option 2 % finished, it does not return into % Main %
The answer should be
result = 1 1 5 4 1 1 2 1
  1 件のコメント
Walter Roberson
Walter Roberson 2018 年 12 月 27 日
you increment n within the inner while loop. that can easily cause n to get towards the 16 that is the end of the outer while loop.

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by