Increase time with for loop
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Chetan Bhavsar
on 5 Apr 2022
Edited: Chetan Bhavsar
on 5 Apr 2022
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 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!