フィルターのクリア

Newbie: The variable (k) of the for loop inside a while

5 ビュー (過去 30 日間)
Sergio
Sergio 2013 年 7 月 17 日
Hi
I have been programming for a short time with matlab and I have a question regarding this code:
for k=2:numel(UntitledCount)
if UntitledCount(k-1)~=UntitledCount(k)
while Voltage(k-11)<Voltage(k-10) && Voltage(k-11)<27
y=y+1;
k=k+1;
end;
topen=y*0.01;
topenarray(m)=topen;
m=m+1;
y=0;
end;
end;
The question is: The variable k, once has been increased during the while, when the condition of the while doesn't meet anymore, and it goes to the for loop again, the value of k remains the same before having been increased during the while loop or does it remain updated after the while?

採用された回答

Iain
Iain 2013 年 7 月 17 日
At the start/end of each for loop, the loop variable is reset to the next value.
for i = 1:5
disp(i)
i = i + 1;
disp(i)
end
Will produce
1
2
2
3
3
4
4
5
5
6
  1 件のコメント
Sergio
Sergio 2013 年 7 月 17 日
many thanks!!!

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

その他の回答 (0 件)

カテゴリ

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