Azzera filtri
Azzera filtri

Complex number output vector instead of real output

2 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

sixwwwwww
sixwwwwww il 31 Ott 2013
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 Commenti
Nikhil
Nikhil il 31 Ott 2013
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 il 31 Ott 2013
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!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by