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

1 回表示 (過去 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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by