フィルターのクリア

For loop is not working

1 回表示 (過去 30 日間)
Adan91h
Adan91h 2017 年 3 月 3 日
コメント済み: Adan91h 2017 年 3 月 4 日
i"m trying to map values of Y(:,:,k) to specific positions of YT(:,:,alpha) but this code is not working.
for alpha=1:NumberofLines
YT(:,:,alpha) = Y(:,:,k);
alpha= j+1
j=j+j
k=k+1
if (alpha > NumberofLines)
break
end
end
Please help!

採用された回答

Image Analyst
Image Analyst 2017 年 3 月 3 日
Where did you set j? Also, redefining your loop iterator, alpha, inside the loop is not advisable. You can do it, but when it gets to the bottom of the loop, it takes on the value from the "for" line, it does not retain the value you set it to. And why are you setting j equal to j+j?
  1 件のコメント
Adan91h
Adan91h 2017 年 3 月 4 日
Thank you so much for your help. I introduced new variable for loop iterator (not using alpha anymore) and now loop works fine.

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

その他の回答 (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