I am observing a error using atan2
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
a warning of this kind is being observed
Warning: Imaginary parts of complex X and/or Y arguments ignored
and a
Error using atan2 Inputs must be real
is being observed.
I = (Ac/2)*real(exp(j*y));
Q = j*(Ac/2)*imag(exp(j*y));
where y is
y = modulate(x,200,1000,'fm');
arctanofy = unwrap(atan2(Q, I));
is to be found
help me out is rectifying the error
1 comentario
KSSV
el 4 de Mzo. de 2016
atan2 accepts only real numbers a input. Read the doc: http://in.mathworks.com/help/matlab/ref/atan2.html
Respuestas (1)
Walter Roberson
el 4 de Mzo. de 2016
Unless you have assigned a value to "j", the expression
Q = j*(Ac/2)*imag(exp(j*y));
will use the default meaning of "j", which is sqrt(-1) . The imag() part around the exp will return a real value, the Ac/2 is real valued, and then you multiply by that imaginary value "j". Your Q will therefore be imaginary. Meanwhile your I has been constructed to be real valued. You are taking atan2(some_complex_value, some_real_value) . And that is failing because atan2 only accepts real values. Which make sense if you think of it, since atan2() attempts to find the proper quadrant for the parameters, but complex values not going to be in the quadrants at all.
You could use
atan(Q/I)
If you do that then the Ac/2 are going to cancel out on the top and bottom, so you would be doing
atan(j*imag(exp(j*y))/real(exp(j*y))
By definition of complex exponentials, exp(j*y) for real y is going to be cos(y)+I*sin(y) so the real component is cos(y) and the imaginary part is sin(y), so you would be doing atan(j*sin(y)/cos(y)) which would be atan(j*tan(y)) . Is that your intent?
modulate() with 'fm' is going to transform its real-valued input into a real-valued output so it is not the case that y is complex itself.
0 comentarios
Ver también
Categorías
Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!