Domain error. To compute complex results, make at least one input complex, e.g. 'power(complex(a),b)'.
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
Torsten
2022-9-16
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 General Applications 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!