for loop index variable change inside the loop[
8 ビュー (過去 30 日間)
古いコメントを表示
I have a very basic coding question but little tricky . Any help would be appreciated
The question follows :
a = [ 3 7 2 6]
x = large size vector
for i = a
for j = x(a,:)
... expression
.. expression
c = find (a > j)
if c ~0
a (c )= a (c) -1;
end
end
end
But for loop index i not changing according to change in variable a. As i came to know from mathwork community it can't be changes . Could some one assit me how to approach this problem.
5 件のコメント
Rik
2022 年 1 月 11 日
Your comment is a bit confusing to me. Did KSSV and Simon solve the problem for you? They posted comments (not answers), so you can't mark them as accepted answer.
回答 (1 件)
Rik
2022 年 1 月 7 日
Once a for loop has started you can no longer change the expression it is based on.
You will have to rewrite your for loop as a while loop.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!