Increase time with for loop
2 ビュー (過去 30 日間)
古いコメントを表示
I am trying to create a variable x that increases by 0.5, 16 times. Thus, at i =16, x it should be 8. I keep running into an error of 'Index exceeds the number of array elements. Index must not exceed 1.'
x=[];
x(1)=0;
for i=1:14
x=x(i)+0.5
end
0 件のコメント
採用された回答
Chetan Bhavsar
2022 年 4 月 5 日
編集済み: Chetan Bhavsar
2022 年 4 月 5 日
You want like this or you want array?
x=0;
for i=1:16
x=x+0.5
end
y={};
x=0;
for i=1:16
x=x+0.5;
y = [y x];
end
y
3 件のコメント
その他の回答 (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!