"Array indices must be positive integers or logical values." - a new problem

조회 수: 2 (최근 30일)
Don
Don 2021년 10월 18일
편집: Cris LaPierre 2021년 10월 18일
First = input('Enter time (secs) for TPlot START \n');
Last = input('Enter time (secs) for TPlot END \n');
Last1 = min(vlength1(2),vlength2(2))-20;
Last2 = min(Last, Last1);
x= Gp1Site2Site1(First:Last2);
y= Gp2Site2Site1(First:Last2);
Array indices must be positive integers or logical values.
Error in MovAvg (line 418)
x= Gp1Site2Site1(First:Last2);
This has worked OK for years. Now it works sometimes but not consistently
Here is the olnly other code than has changed:
'C:\Projects\ParkinsonsProject\JaneBird\'
I cannot find the problem Can anyone spot the issue"

답변 (1개)

Cris LaPierre
Cris LaPierre 2021년 10월 18일
편집: Cris LaPierre 2021년 10월 18일
What are your input values for First and Last? What are the values for vlength1 and vlength2?
The error means you are trying to use either negative or decimal values to index a variable. Indices must be integer values >=1.
A = 1:3;
% Works when index is an integer
a = A(2)
a = 2
% Error when index is a decimal
b = A(1.2)
Array indices must be positive integers or logical values.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by