Undefined Function Error when Calling MATLAB function containing a parfor loop via API for Python

I receive an UndefinedFunction error for the sliced output variable: 'fvalsT' when calling the function 'PyModelFit' via Python. All directories are correct, and when called from the Matlab command window, the parfor loop executes as expected. As seen in the code below, the 'fvals' variables are properly initialized. This error only seems to occur when utilizing the integration with Python.
I am currently using Python 3.5.2. Thank you for any assistance in identifying the problem!
function [solution,solFlag,AIC,solutionset] = PyModelFit(subjchoices,selectOptions,fmins)
fvalsT = zeros(1,fmins);
fvalsO = zeros(1,fmins);
fvalsG = zeros(1,fmins);
fvalsE = zeros(1,fmins);
fvalsTT = zeros(1,fmins);
solsTDiscount = cell(1,fmins);
solsObj = cell(1,fmins);
solsG = cell(1,fmins);
solsExp = cell(1,fmins);
solsTT = cell(1,fmins);
TempDiscountMLE = @(x)TimeVaryTempDiscountMLE(x,subjchoices,selectOptions);
parfor n = 1:fmins %parallelize
gamma0 = 0.1*rand(1);
beta0 = 0.1*rand(1);
x0 = [gamma0,beta0];
[sol,fval] = fminsearch(TempDiscountMLE,x0);
fvalsT(n) = fval;
solsTDiscount(n) = {sol};
end
id_Temp = find(fvalsT == min(fvalsT));
...
...

 채택된 답변

For those who come across this problem, I believe it's been solved. It's related to the int64 par-for bug as outlined in this answer thread: https://www.mathworks.com/matlabcentral/answers/363559-parfor-fails-with-loop-indices-being-uint64

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

질문:

2018년 3월 15일

답변:

2018년 3월 16일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by