MCR executable different than original code

조회 수: 5 (최근 30일)
Kurt
Kurt 2012년 3월 15일
답변: cem polat 2015년 8월 6일
I am using matlab to compile an .exe file, but when I run it I get error messages in several places that do not cause errors in the original code. For example, when I use the pdf function (from gmdistribution in the stats toolbox, which I included when compiling) I get:
Original code (gmq is definitely a distribution):
t=pdf(gmq,[xx(:,1) xx(:,2) xx(:,3)]);
Error message: {Error using pdf (line 54)
Requires the first input to be the name of a distribution.
Error in expectationsf_v1 (line 45)}
stats:pdf:BadDistribution
I've was able to get around this error somewhat. The problem (thanks Kaustubha!) was that the pdf function cannot tell that I am referring to the gmdistribution class when it's compiled, so I renamed the function gmpdf. That still didn't work though because there seems to be a problem with using objects in compiler. For example, when I run something like:
gm_cells{i,p}=gmdistribution.fit(xdata{s,q,ff},1,'Start','randSample','Options',options,'Regularize',1,'SharedCov',true,'Replicates',200);
gm{i,1}=gm_cells{i,p}.mu;
gm{i,2}=gm_cells{i,p}.Sigma;
gm{i,3}=gm_cells{i,p}.PComponents;
When I run this in matlab it works fine, but when I compile it and run the .exe I get the error message:
{Attempt to reference field of non-structure array.
Error in model13_main (line 243)
}
MATLAB:nonStrucReference
Does anyone have ideas about what the problem may be, or how to debug the code given that I can't replicate the error messages in matlab? I'm using 2011b and MCR version 7.16.
  댓글 수: 3
Kaustubha Govind
Kaustubha Govind 2012년 3월 16일
And thus the recommendation to contact Tech Support. :)
Arjun Viswanathan
Arjun Viswanathan 2014년 4월 4일
I had a similar error. The solution was to make sure all my classdef .m files were included in the "Files required for your application to run" box in applicationCompiler. That solved the issue for me.

댓글을 달려면 로그인하십시오.

답변 (3개)

Kaustubha Govind
Kaustubha Govind 2012년 3월 15일
It seems like the deployed version of the code is picking up the generic version of the pdf function which expects the first argument to be a string containing the name of a distribution, instead of gmdistribution.pdf. Somehow, the gmdistribution class is not getting compiled and included in the CTF correctly. I would recommend contacting MathWorks Tech Support if this is a bug that they have a resolution for.

owr
owr 2012년 3월 16일
Whenever I run into errors like this using objects in a deployed appllication, I try the fix described here:
I havent looked at the details of your specific case much, but its an easy quick test.
Good luck.

cem polat
cem polat 2015년 8월 6일
I had the same problem with Matlab 2014b and java compiled MCR code. I used fitgmdist instead of gmdistribution.fit and my problem was solved. Now that both MATLAB and java MCR class method works the same. fitgmdist is also offered by MATLAB help since gmdistribution.fit will be removed in a future release.

카테고리

Help CenterFile Exchange에서 Application Deployment에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by