How do I solve “pyrunfile is not suppoted” error in MATLAB Function ?
I got these errors in MATLAB Function. I tried everything but I couldn’t figure out how to solve. I’m not sure.
Could you give me any advice? I’d be happy if you could tell me why this happens and where I’m missing.
Also, I’m now executing this model on MATLAB Online.
Error1
The function ‘pyrunfile’ is not supported in code generation.
Function ‘MATLAB Function’ (#24.95.220), line 2, column 13:.
“pyrunfile(“scikit_learn_model.py”, “output_vars”,in1=input1,in2=input2,in3=input3")
Error2
Terminal width or dimension error.
‘Output terminal 1’ in ‘MATLAB Function/input7’ is a 1-dimensional vector with 1 element
Here is my .slx model.
Also, Here is my MATLAB Function code.
function [trq,brake] = RunPython(input1,input2,input3,input4,input5,input6,input7)
outputs=pyrunfile("scikit_learn_model.py","output_vars",in1=input1,in2=input2,in3=input3,in4=input4,in5=input5,in6=input6,in7=input7);
trq=outputs(1);
brake=outputs(2);
end
scikit_learn_model.py
import pickle
with open(‘surrogate_model.pkl’, ‘rb’) as f:
model = pickle.load(f)
inputs = [in1,in2,in3,in4,in5,in6,in7]
output1, output2 = model.predict(inputs)
output_vars=[output1,output2]I got these errors in MATLAB Function. I tried everything but I couldn’t figure out how to solve. I’m not sure.
Could you give me any advice? I’d be happy if you could tell me why this happens and where I’m missing.
Also, I’m now executing this model on MATLAB Online.
Error1
The function ‘pyrunfile’ is not supported in code generation.
Function ‘MATLAB Function’ (#24.95.220), line 2, column 13:.
“pyrunfile(“scikit_learn_model.py”, “output_vars”,in1=input1,in2=input2,in3=input3")
Error2
Terminal width or dimension error.
‘Output terminal 1’ in ‘MATLAB Function/input7’ is a 1-dimensional vector with 1 element
Here is my .slx model.
Also, Here is my MATLAB Function code.
function [trq,brake] = RunPython(input1,input2,input3,input4,input5,input6,input7)
outputs=pyrunfile("scikit_learn_model.py","output_vars",in1=input1,in2=input2,in3=input3,in4=input4,in5=input5,in6=input6,in7=input7);
trq=outputs(1);
brake=outputs(2);
end
scikit_learn_model.py
import pickle
with open(‘surrogate_model.pkl’, ‘rb’) as f:
model = pickle.load(f)
inputs = [in1,in2,in3,in4,in5,in6,in7]
output1, output2 = model.predict(inputs)
output_vars=[output1,output2] I got these errors in MATLAB Function. I tried everything but I couldn’t figure out how to solve. I’m not sure.
Could you give me any advice? I’d be happy if you could tell me why this happens and where I’m missing.
Also, I’m now executing this model on MATLAB Online.
Error1
The function ‘pyrunfile’ is not supported in code generation.
Function ‘MATLAB Function’ (#24.95.220), line 2, column 13:.
“pyrunfile(“scikit_learn_model.py”, “output_vars”,in1=input1,in2=input2,in3=input3")
Error2
Terminal width or dimension error.
‘Output terminal 1’ in ‘MATLAB Function/input7’ is a 1-dimensional vector with 1 element
Here is my .slx model.
Also, Here is my MATLAB Function code.
function [trq,brake] = RunPython(input1,input2,input3,input4,input5,input6,input7)
outputs=pyrunfile("scikit_learn_model.py","output_vars",in1=input1,in2=input2,in3=input3,in4=input4,in5=input5,in6=input6,in7=input7);
trq=outputs(1);
brake=outputs(2);
end
scikit_learn_model.py
import pickle
with open(‘surrogate_model.pkl’, ‘rb’) as f:
model = pickle.load(f)
inputs = [in1,in2,in3,in4,in5,in6,in7]
output1, output2 = model.predict(inputs)
output_vars=[output1,output2] python, matlab function MATLAB Answers — New Questions