compiling matlab code: works in Matlab but not in cmd.exe

1 view (last 30 days)
Hello all,
I have a program that use parallel toolbox. That works perfectly in Matlab but when I compile it and execute it in cmd.exe, I get this error: Matlab cannot determine whether 'gmdistribution' refers to a function or variable. See Parallel for Loops in Matlab, 'Unambiguous Variable Names'. Matlab:mir_error_parfor_ambiguous_name.
The program crashes in this row:
gm{k} = gmdistribution.fit(X,ngseq(k),...
'Regularize',Regularize,...
'Replicates',Replicates,...
'Start',Start,...
'CovType',CovType,...
'SharedCov',SharedCov,...
'Options',gmoptions);
I'm using matlab (2014a) and mcr 8.3 (2014a)| Thank you
  1 Comment
Ben
Ben on 9 Oct 2014
Edited: Ben on 9 Oct 2014
i have the same problem. even if i change the parfor to a for, the compiled code errors out on gmdistribution saying it is an undefined variable or class. this is with 2014a on 64-bit linux. works fine on the command line though.

Sign in to comment.

Answers (2)

Titus Edelhofer
Titus Edelhofer on 9 Oct 2014
Hi,
I'm not sure yet about the parfor part of the question. You are right, the compiler should pick up the code automatically. As a workaround you can help him here by adding the folder matlabroot\toolbox\stats\stats\@gmdistribution to the "Files required for your application to run". It should then add all files of that folder, and then (at least without parallel computing) it works. Since in this case parfor "knows" what gmdistribution.fit is, my guess is, that the parfor problem will go away as well.
Titus

Titus Edelhofer
Titus Edelhofer on 9 Oct 2014
Hi,
I just made another test: replacing gmdistribution.fit by fitgmdist (as the help for gmdistribution.fit suggests, because gmdistribution.fit will be removed) solves the problem as well.
It looks as if the compiler is one step ahead of MATLAB ;-).
Titus

Categories

Find more on Parallel Computing Fundamentals in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!