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

1 vue (au cours des 30 derniers jours)
Don
Don le 18 Oct 2021
Modifié(e) : Cris LaPierre le 18 Oct 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"

Réponses (1)

Cris LaPierre
Cris LaPierre le 18 Oct 2021
Modifié(e) : Cris LaPierre le 18 Oct 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.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by