Getting error in MEX file execution

조회 수: 1 (최근 30일)
Caleb
Caleb 2016년 10월 26일
편집: Caleb 2016년 10월 26일
I'm doing parameter tuning for an equation of state using the genetic algorithm function (ga). When I run the equation of state file as I coded it in MATLAB, it works fine. When I compile and package the file as a MEX file, it gives me the following error:
Error using
coder.internal.error (line
17)
Domain error. To compute
complex results from real x,
use 'log(complex(x))'.
Error in log (line 13)
coder.internal.error('Coder:toolbox:ElFunDomainError',mfilename);
Error in EOSfunction (line 552)
logPHI = MUres_kT - log(Z);
What could be causing this? I have checks to make sure that Z is always real and non-negative, so log(Z) should never be causing a problem.
  댓글 수: 2
Walter Roberson
Walter Roberson 2016년 10월 26일
As an experiment, just above that logPHI line, add
assert(Z > 0);
and see what happens.
Caleb
Caleb 2016년 10월 26일
편집: Caleb 2016년 10월 26일
Didn't work. Here's the error statement:
Error using EOSfile (line 552)
Assertion failed.
EDIT: I guess "Assertion failed" means that Z is returning a negative number. That was the fix. Thank you, Walter

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by