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.
Best Answer