Info

This question is closed. Reopen it to edit or answer.

MATLAB Function Interface Error: Domain error. To compute complex results, make at least one input complex, e.g. 'power(complex(a),b)'.

5 views (last 30 days)
hi, how can i resolve this error?: Domain error. To compute complex results, make at least one input complex, e.g. 'power(complex(a),b)'. the error seems to be the program line:
h2=(4*sin(el)^2*(G - F*(F^2 + G^2 - 1)^(1/2))^2*(1 + (F^2 + G^2 - 1)^(1/2)*1i)^2)/((F*1i - G)^2*(F^2 + G^2)^2);
h3=(8*sin(el)*(G - F*(F^2 + G^2 - 1)^(1/2))*(1 + (F^2 + G^2 - 1)^(1/2)*1i)^2)/((F*1i - G)^2*(F^2 + G^2));
h4=(sin(el)*(1 + (F^2 + G^2 - 1)^(1/2)*1i)^2*1i)/(F*1i - G)^2;
a=-log(((F^2 + G^2)^2*(h1*1i + (2*(1 + (F^2 + G^2 - 1)^(1/2)*1i)*1i)/(F*1i - G) - ((4*(1 + (F^2 + G^2 - 1)^(1/2) * 1i)^2)/(F*1i - G)^2 + X2^2 + X3^2 - (2*X2^2*(1 + (F^2 + G^2 - 1)^(1/2)*1i)^2)/(F*1i - G)^2 +(X2^2*(1 + (F^2 + G^2 - 1)^(1/2)*1i)^4)/(F*1i - G)^4 - (2*X3^2*(1 + (F^2 + G^2 - 1)^(1/2)*1i)^2)/(F*1i - G)^2 + (X3^2*(1 + (F^2 + G^2 - 1)^(1/2)*1i)^4)/(F*1i - G)^4 + h2 - h3)^(1/2)*1i + h4))/(2*(G + F*1i)^2*(X2 - X3*1i)*(1 - G^2 + F*G*1i + (F^2 + G^2 - 1)^(1/2)*1i)))*1i;
  3 Comments
studentU
studentU on 21 May 2015
[I am confused now. Is this in Simulink or is this at the MATLAB command prompt? If it is at the MATLAB command prompt, then I need to a current copy of the line that failed and I need to know the values it fails on -- a sample el, F, G] by Roberson
At the command prompt it's run very well, I remember u that F and G are scalar numeric values, you can take to F = -0, 883, and G = 0.0987, the result is complex format.
but, I'm working in simulink, in matlab function block, where I am blocked, and where it generates this error :/

Answers (0)

Community Treasure Hunt

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

Start Hunting!