필터 지우기
필터 지우기

Complex number output vector instead of real output

조회 수: 4 (최근 30일)
Nikhil
Nikhil 2013년 10월 31일
댓글: sixwwwwww 2013년 10월 31일
Hey all,
I am solving for three equations using given input vector. My input vector is of real numbers. But the output vector is of complex numbers whose complex coefficient is zero. I am unable to understand why Matlab is giving complex output for certain elements even complex term is zero. The code I am analyzing is as follows:
dr=0.055:0.00001:0.063;
for i=1:1:length(dr)
pd=0.015;Fr=8900;Z=9;Kn=3.735e5;
phi1=acos(pd/(2*dr(i)));
epsi=0.5*(1-pd/(2*dr(i)));
f=@(theta)(1/(2*pi)*(1-(0.5/epsi)*(1-cos(theta))).^(1.5).*cos(theta));
Jr(i)=quad(f,-phi1,phi1);
fl(i)=Fr-(Z*Kn*(dr(i)-0.5*pd)^(1.5)*real(Jr(i)));
end;
If we see at the output certain elements of Jr vector are complex. Can somebody tell me why MATLAB is giving answer for certain elements in complex format even if there complex term is zero ? Thanks in advance,
Nikhil

채택된 답변

sixwwwwww
sixwwwwww 2013년 10월 31일
Dear Nikhil, you can use following line of code to see imaginary part of Jones vector
ImaginaryPartofJr = imag(Jr)
and you will see that not all the terms are 0 but they are very very small values like ~10^-27 but not actually 0 and due to this reason MATLAB showing Jr as array of complex doubles. I hope it answers your confusion. Good luck!
  댓글 수: 2
Nikhil
Nikhil 2013년 10월 31일
Hey, thanks for your answer. My doubt is theoretically all the elements in the output vector should be real. Why MATLAB is giving me complex output for given set of parameter values? Since the complex terms are too small, its values should be zero. Thanks in advance,
sixwwwwww
sixwwwwww 2013년 10월 31일
I assume that it has to do with quad function in MATLAB that how the integral is evaluated over the given period. One way to look at it is to reproduce the same function in symbolic form, then integrate it and put the values of phi1 at which Jr becomes complex and then you can have deeper insight into it. It seems long work around to understand physical meaning but actually it is not that long. I hope you can try and find something interesting with it. Good luck!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by