Index in position 2 is invalid. Array indices must be positive integers or logical values.

1 回表示 (過去 30 日間)
Barb
Barb 2019 年 12 月 17 日
回答済み: Guillaume 2019 年 12 月 18 日
I have a problem. I want to do a speech command recognition,
This error occurs when I try to make spectograms with my own data. I don't know what format this voice data should be. I recorded them using audacity and exported them as: Mono, 32-bit folat with a frequency of 16000 HZ each 'yes' is 1 length one second. I don't know where to change or what format the recording should be to load it. I don't know if this is a mistake in the code or badly saved sound files.
Index in position 2 is invalid. Array indices must be positive integers or logical values.
Error in speechSpectrograms (line 41)
X(:,ind,1,i) = spec;
The attachment added is the code from speechSpectrograms
  5 件のコメント
Barb
Barb 2019 年 12 月 18 日
ind = 1x99 double
i =1
numHops = 98
spec =40x99 double
Star Strider
Star Strider 2019 年 12 月 18 日
The ‘ind’ vector must only contan integers greater than 0 to use it as an index.

サインインしてコメントする。

回答 (1 件)

Guillaume
Guillaume 2019 年 12 月 18 日
The error message is clear, the index in position two is invalid because it contains either non-integer values or values less than one.
The index in position two is the ind variable, so look inside that variable and see what the values are. They're going to be integer due to the way you construct ind, but if left is 0 or negative, then some ind values will indeed be invalid.
You can then work backward throught the code to find why left is less than 1. Without any of your inputs it's not something we can answer. Possible reason at first glance is that size(spec, 2) is greater than numHops.
By the way, isn't spec a vector? In which case, numel(spec) would be simpler and safer than size(spec, 2).

カテゴリ

Help Center および File ExchangeSignal Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by