Complex number output vector instead of real output
3 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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 个评论
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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!