how can i solve it
조회 수: 2 (최근 30일)
이전 댓글 표시
i=1:100;
vx_1(i)=(X1(i)-X1((i)-1))/(t(i)-t((i)-1)); % In general
vx_1(1)= (X1(1)-X1(N-1))/(t(N)-t(N-1)); % for i=1
I get the error: Array indices must be positive integers or logical values.
How can I solve it
it works well when you put i= single digit but does not work for array? eg it works well when i=6
채택된 답변
Walter Roberson
2021년 8월 18일
When i is 1 then i-1 is 0, and you would be referring to X1(0) and t(0) .
MATLAB cannot use index 0.
See my discussion in https://www.mathworks.com/matlabcentral/answers/1413192-z-must-be-a-matrix-not-a-scalar-or-vector#comment_1693702 for what needs to be done.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!