why get this message "Array indices must be positive integers or logical values." i for loop?

조회 수: 1 (최근 30일)
I got the error message " Array indices must be positive integers or logical values"
I would appreciate any help. thanks in advance
for i = 1:0:1:600
iNext = i + 1;
do...
x(iNext) >= x(i) % assumed "i" is the current step and "iNext" is the Next step
end

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2022년 5월 15일
편집: KALYAN ACHARJYA 2022년 5월 15일
Yes, Matlab allows indexing for positive integer only
x=zeros(1,600);
for i = 1:600
iNext=i + 1;
x(iNext)=x(i) % assumed "i" is the current step and "iNext" is the Next step
end
#Pls see the iteration process and your requirements

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by