Why do I get a domain error regarding complex numbers when running mex functions created by MATLAB Coder 2.4 (R2013a)?
Show older comments
I mex some self-written function. For that function, the code generation works perfect. However, when running the code I get an error:
Domain error. To compute complex results from real x, use 'sqrt(complex(x))'.
Error in eml_error (line 20)
eml_rterror(eml_const(msgId),varargin{:});
Error in sqrt (line 14)
eml_error('Coder:toolbox:ElFunDomainError','sqrt');
Error in stcc_garch_likelihood_conditioned_on_stcc (line 58)
stdresid(:,1)=data(:,1)./sqrt(ht(:,1));
This can also happen with functions like LOG:
Domain error. To compute complex results from real x, use 'log(complex(x))'.
The confusing thing is: When I run the non-mexed file, I do not get the error. It works perfectly. Same thing when running it as a script. So, function works perfectly, coding to mex works perfectly, but the mex file doesn't work.
Accepted Answer
More Answers (0)
Categories
Find more on Code Performance 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!