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

2 Ansichten (letzte 30 Tage)
Don
Don am 18 Okt. 2021
Bearbeitet: Cris LaPierre am 18 Okt. 2021
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"

Antworten (1)

Cris LaPierre
Cris LaPierre am 18 Okt. 2021
Bearbeitet: Cris LaPierre am 18 Okt. 2021
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.

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by