Warning: Imaginary parts of complex X and/or Y arguments ignored.

2 ビュー (過去 30 日間)
Opariuc Andrei
Opariuc Andrei 2021 年 12 月 6 日
コメント済み: Jon 2021 年 12 月 6 日
Error when attempting to plot ,the first imaginary result comes from Q3 afterwards everything that involves Q3 results as imaginary , i tried doing q3=sqrt(h3)*k; Q3=real(q3); and got rid of the imaginary result (i think) but when trying to plot my plot is empty
%% initial data
p32 = [1.22 1.225 1.225 1.22 0.765 0.085];
p33 = [0.660 0.660 0.665 0.655 0.435 0.085];
p34 = [0.830 0.830 0.830 0.815 0.540 0.105];
p39 = [0.705 0.705 0.730 0.690 0.460 0.085];
p40 = [0.410 0.410 0.405 0.400 0.285 0.090];
d=0.051;
k=0.064;
niu=1.01*10^(-6);
g=9.81;
L1=0.5 ;
L2= 1;
L=1.5;
%%
h1=p32-p33;
h2=p34-p39;
h3=p39-p40;
Q1=sqrt(h1)*k;
Q2=sqrt(h2)*k;
Q3=sqrt(h3)*k
S=(pi*d^2)/4;
V1=Q1/S;
V2=Q2/S;
V3=Q3/S;
Re1=(V1*d)/niu;
Re2=(V2*d)/niu;
Re3=(V3*d)/niu;
j1=h1/L;
j2=h2/L;
j3=h3/L;
he1=h1+j1*(L1+L2);
he2=h2+j2*(L1+L2);
he3=h3+j3*(L1+L2);
re1=Q1*4/pi*d^2;
re2=Q2*4/pi*d^2;
re3=Q3*4/pi*d^2;
zita1=he1*2*g/(re1.^2);
zita2=he2*2*g/(re2.^2);
zita3=he3*2*g/(re3.^2);
he1=zita1*re1.^2/2*g;
he2=zita2*re2.^2/2*g;
he3=zita3*re3.^2/2*g;
%%
figure
plot(Re1,real(zita1),'c');hold on;
plot(Re2,real(zita2),'r');
plot(Re3,real(zita3)','g');
grid on;axis tight;

採用された回答

Jon
Jon 2021 年 12 月 6 日
Haven't tried your code, but most likely one or more of h1, h2, or h3 are negative and when you take the square root of them it generates a complex value. In the future please include the error in the body of your question and put a more descrptive subject in
  1 件のコメント
Jon
Jon 2021 年 12 月 6 日
I looked at your code a little more. The problem is in the last element of h3. Since p39(4) = 0.085 and p40(4) = 0.090 the last element of h3 = p39-p40 is negative. Then on line 21 you compute Q3 as sqrt(h3)*k which gives a purely imaginary result in the fourth element of Q3, and as you say the problems cascade from there.
Rather than trying to mask the problem by taking just real parts I think you need to figure out what your physical interpertation is of the negative, what looks like a pressure difference, is in the fourth term of h3.
Looks like maybe the flow is reversed. If you just care about the magnitude of the flows and not the directions I would suggest computing
h3 = sqrt(abs(h3))*k

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by