Increase time with for loop
조회 수: 4 (최근 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에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!