How can i solve this matlabruntime error that i have calling a Matlab function in Python?
4 views (last 30 days)
Show older comments
I packaged a Matlab function using the Compiler SDK that i called 'loadModelEstimateStates'. The name of my package is 'BDLMmodelLoaderEstimator2'.
This matlab function has 2 inputs which are the path and the name of another matlab script that i need to RUN in order to obtain a machine learning model parameters (data, option, model matrices).
Everything works well RUNNING my function in Matlab and also using the Matlab Engine API. But trying to call the compiled package in python i face the matlabruntime error below :
MatlabRuntimeError: An error occurred when evaluating the result from a function. Details: File C:\Program Files\MATLAB\R2021a\mcr\toolbox\matlab\lang\run.m, line 78, in run File C:\Users\CAMP1\AppData\Local\Temp\CAMP1\mcrCache9.10\BDLMmo3\BDLMmodelLoa\CAMP_scripts\loadModelEstimateStates.m, line 8, in loadModelEstimateStates C:\Users\CAMP1\Desktop\BDLM_V2_mod\config_files\CFG_LTU_PEN_A_DETECT_V2.m not found.
The error seems occur at line 8 of my matlab function with the RUN statement.
These are my matlab function and how i invoke it in Python.
I tryied many things like manage security of the folder containing the file to RUN and also change the location of this folder etc., but still have the same issue.
Can someone please help me to solve this problem? Thank you very much.
Matlab function :
function [localLevel,cyclical,dates] = loadModelEstimateStates(configFileName,configFilePath)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
% must run the model configuration file the will return the matricies
% of the model
run([strcat(configFilePath,configFileName)]);
% given the matricies for the model we must run the model initalisation
[model,data,option]=model_initialisation(model,data,option);
% estimate the hidden states from the model
estim = estimation.state_estimation(data,model,option);
% extract the locallevel and the cyclical hidden states
localLevel = estim.x(1,:);
cyclical = estim.x(4,:);
dates = data.timestamps;
end
Python call of the function:
import BDLMmodelLoaderEstimator2
import matlab
my_loadModelEstimate2 = BDLMmodelLoaderEstimator2.initialize()
#Enregistrement du premier input dans l'objet Input1
Input1 = "\CFG_LTU_PEN_A_DETECT_V2.m"
print(Input1)
Input2 = "C:\\Users\\CAMP1\\Desktop\\BDLM_V2_mod\\config_files"
print(Input2)
InitModelEstimate = my_loadModelEstimate2.loadModelEstimateStates(Input1, Input2)
my_loadModelEstimate2.terminate()
0 Comments
Answers (0)
See Also
Categories
Find more on Call Python from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!