Why am I getting complex values?
Mostra commenti meno recenti
In this portion of my code I am getting complex values for HJ. There are 3 loops and each loop has 4 pipes.
% pipe length in ft
ZL(1,1) = 10560; ZL(1,2) = 15840; ZL(1,3) = 10560; ZL(1,4) = 15840;
ZL(2,1) = 15840; ZL(2,2) = 13200; ZL(2,3) = 10560; ZL(2,4) = 10560;
ZL(3,1) = 15840; ZL(3,2) = 15840; ZL(3,3) = 15840; ZL(3,4) = 15840;
% pipe dimensions in feet
D(1,1) = 16/12; D(1,2) = 12/12; D(1,3) = 14/12; D(1,4) = 16/12;
D(2,1) = 16/12; D(2,2) = 14/12; D(2,3) = 12/12; D(2,4) = 16/12;
D(3,1) = 12/12; D(3,2) = 10/12; D(3,3) = 12/12; D(3,4) = 12/12;
%Initial Flow
Q(1,1) = 3.0; Q(1,2) = 1.5; Q(1,3) = -1.6; Q(1,4) = -4.0;
Q(2,1) = 3.8; Q(2,2) = 1.7; Q(2,3) = 0.3; Q(2,4) = -3.0;
Q(3,1) = 1.8; Q(3,2) = 0.4; Q(3,3) = -1.0; Q(3,4) = -1.5;
c= 140;
for i = 1:3
for j = 1:4
a = pi*D(i,j)^2 /4;
HJ(i,j) = (3.022*((Q(i,j)/a)^1.85)*ZL(i,j))/(c^1.85*D(i,j)^1.165);
end
end
4 Commenti
Anthony Cavalieri
il 18 Giu 2020
KSSV
il 18 Giu 2020
After quckly checking your pdf,,,see the matrix D, it has negative values.....the power of D i.e D^1.85 will be complex.
KSSV
il 18 Giu 2020
You need not to define each elemtn of matrix...you can staright away type
D = [3 1.5 ....; ]
Give all the elements in rows and columns..you can avoid typing more..be lazy. :)
Risposte (1)
madhan ravi
il 18 Giu 2020
I don’t know why you’re surprised:
>> (-1)^1.85 % if the value is negative
ans =
0.8910 - 0.4540i
Categorie
Scopri di più su Interpolation in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!