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));
...
...

 采纳的回答

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Call Python from MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by