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

2 次查看(过去 30 天)
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