Why do I get "Array indices must be positive integers or logical values." Error
이전 댓글 표시
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
KSSV
2021년 12월 15일
I don't think this variable
my_input = my_input';
is not defined in the function.
Semih Yönet
2021년 12월 15일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Reinforcement Learning에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!