MATLAB Answers

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

4 views (last 30 days)
Barb
Barb on 17 Dec 2019
Answered: Guillaume on 18 Dec 2019
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 Comments

Show 2 older comments

Sign in to comment.

Answers (1)

Guillaume
Guillaume on 18 Dec 2019
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).

  0 Comments

Sign in to comment.

Sign in to answer this question.