Index Error in python with matlab code
4 ビュー (過去 30 日間)
古いコメントを表示
Hi,
so I've written a function in matlab which gives six inputs to a number of neuralnetworks saved in "nets", which is a cell array and returns a vector, containing one result per network:
function e = network_evaluation(s0,s1,s2,s3,s4,s5)
var = load("Network_single_output(6-2-1).mat", "nets");
in = [s0, s1, s2, s3, s4, s5]';
n = var.nets;
e = zeros(1,length(n));
for i = 1:length(n)
e(i) = n{i}(in);
end
end
I have then used to Matlab Compiler SDK to get a Python Package which I succesfully installed and called in Python.
When I run my function though, I get an error:
Warning: Class 'network' is an unknown object class or does not have a valid 'loadobj' method. Element(s) of this class in array 'nets' have been converted to structures.
> In net_ev (line 2)
Index exceeds the number of array elements (1).
Error in net_ev (line 7)
Traceback (most recent call last):
File path, line 11, in <module>
result = netting.net_ev(1,2,3,4,5,6)
File path, line 80, in __call__
nlhsWasSpecified, stdoutObj, stderrObj).result()
File "C:\Program Files\MATLAB\R2019b\toolbox\compiler_sdk\pysdk_py\matlab_pysdk\runtime\futureresult.py", line 135, in result
raise e
matlab_pysdk.runtime.MatlabRuntimeError: An error occurred when evaluating the result from a function. Details:
File path\net_ev.m, line 7, in net_ev
Index exceeds the number of array elements (1).
(I have replaced the acutally file path here with "path").
I have already tried to use
length(n)-1
but it didn't work. Does anyone have an idea what the issue might be?
Thanks in advance!
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Python Package Integration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!