Change step value within a for loop.
3 ビュー (過去 30 日間)
古いコメントを表示
Hi
for i = 1:10
i
i = 6;
end
what I'm trying to do is let i = 1, 6, 7, 8, 9,10, but instead, MATLAB shows that 1,2,3,4,5,6,7,8,9,10. is there any way to do that? I'm aware that in a for loop, the "end" will reset the step value. Please help me to solve this problem
0 件のコメント
回答 (1 件)
Azzi Abdelmalek
2016 年 7 月 26 日
編集済み: Azzi Abdelmalek
2016 年 7 月 26 日
for i = [1 6:10]
y=i
end
2 件のコメント
Azzi Abdelmalek
2016 年 7 月 26 日
If you want i = 1,6,19,30, 61,89,100 then write
i = [1,6,19,30, 61,89,100]
I don't understand what is your problem with that. It don't work like you are asking, because this is how for loop works in Matlab !
参考
カテゴリ
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!