Domain error. To compute complex results, make at least one input complex, e.g. 'power(complex(a),b)'.
9 views (last 30 days)
Show older comments
Hi, Im getting the following error:
Domain error. To compute complex results, make at least one input complex, e.g. 'power(complex(a),b)'.
function y = fcn(u, Pm)
Cd = 1; %Discharge Coefficient (determined expermentally = actual mass flow/ideal mass flow)) [-]
P0 = 1.01*10^5; %Ambient pressure [Pa]
R = abs(287.1); %Gas constant [J/(kg*K)]
T0 = abs(293.15); %Atmospheric temp [K]
gamma = 1.4; %exponent [-]
q = (Cd*u*P0)/(sqrt(R*T0));
w = (Pm/P0)^(1/gamma);
e = (2*gamma)/(gamma-1);
f = (1.4-1)/1.4;
r = 1-(Pm/P0);
r = r^f;
x6 = q*w*(e*r)^(0.5);
y = x6;
Could anyone please help me? I do not require a complex solution (as far as I know, it should be just a number) and i've tried a lot: complex() and abs() (to try to tell matlab that it is a positive double).
thank you so much.
4 Comments
Torsten
on 16 Sep 2022
Pm is not, cannot and will not be a negative double
Might be. Then Pm becomes greater than P0 during the solution process which makes r negative.
Line 14 is r = r^f;
(Which works if I replace 'f' with a 1 but doesn't work when I replace it with 0.5 for example. (??)
Yes, r seems to become negative. Thus r^f becomes complex for non-integers f.
Answers (0)
See Also
Categories
Find more on General Applications 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!