Abs and angle of complex number with symbolic object
Mostrar comentarios más antiguos
Hi,
If r=sym('a')*exp(j*sym('b')) is a symbolic object, and
1. if I write abs(r), I get abs(a).....I need get only "a" without abs
2. if I write angle(r), I get error
??? Undefined function or method 'atan2' for input arguments of type 'sym'.
Error in ==> angle at 14 p = atan2(imag(h), real(h));
Can you help me please? How can I solve this?
Respuesta aceptada
Más respuestas (1)
Well, for part 1 you have to assume a is a non-negative real:
syms a
assume(a>0)
Then
>> abs(a)
ans =
a
I have not tried the second part, but you can imagine dividing by the magnitude and taking a log....
6 comentarios
Brian B
el 4 de Mzo. de 2013
You may also have to
assume(b,'real')
john
el 4 de Mzo. de 2013
Editada: Walter Roberson
el 4 de Mzo. de 2013
Brian B
el 4 de Mzo. de 2013
What version of the Symbolic Math Toolbox do you have?
ver('symbolic')
john
el 4 de Mzo. de 2013
Try
a = sym('a','positive')
b = sym('b','real')
That works for me in R2011b, including computing the magnitude of r. I don't see a good way to get the argument, though.
john
el 5 de Mzo. de 2013
Categorías
Más información sobre Special Values en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!