Why do I get "Array indices must be positive integers or logical values." Error
Afficher commentaires plus anciens
Hello,
I've been getting an error, trying to classify a sound. My problem is that when I run my code in Matlab Workspace, it works. However, if I connect to Matlab session in python to run the code, I get this error.
Array indices must be positive integers or logical values.
Error in classify_input (line 13)
my_output = netw(my_input); %input the sample test in the NN
Here's my full matlab code:
function [result] = classify_input(input_location)
global net_stg9; % Previously trained network
netw = net_stg9;
[audioIn, Fs] = audioread(input_location);
my_input = mfcc(audioIn, Fs);
my_input = my_input';
my_input = reshape(my_input, [], 1);
my_output = netw(my_input); %input the sample test in the NN
myClass = max(my_output);
counter = 0;
for i = 1:6
counter = counter + 1;
if (my_output(i, 1) == myClass)
break;
end
end
accuracy = round(myClass * 100);
result = (counter * 1000) + accuracy;
My python code:
matlab_session = matlab.engine.find_matlab()[0]
eng = matlab.engine.connect_matlab(matlab_session)
data = eng.classify_input( './filename1-1.wav');
Any help is appreciated! Thank you.
2 commentaires
KSSV
le 15 Déc 2021
I don't think this variable
my_input = my_input';
is not defined in the function.
Semih Yönet
le 15 Déc 2021
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Reinforcement Learning dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!