how to get the argument and the modulus of a analytic complex function?

11 views (last 30 days)
clear all
syms a b c
as a result in the command window i am getting :
arg = angle(a*exp(b*c*1i))
mod= abs(a*exp(b*c*1i))
but what i want is :
arg= b*c
mod= a
any sugestion ?
thank you in advance

Answers (1)

John D'Errico
John D'Errico on 7 Dec 2021
Edited: John D'Errico on 7 Dec 2021
The use of mod as the name of a variable is a REALLY bad idea. Soon, when you begin using MATLAB more, you will trip over things like this, and then post a frantic question here, asking why does the mod function no longer work properly in MATLAB? (Or some similarly anxious question.) So don't use names like mod.
Your basic problem in that code, is the answer you want to get is not valid, at least if some of those parameters are not real numbers. But if we do this, restricting a,b,c to be all real valued,
syms a b c real
z = a*exp(i*b*c);
ans = 
Note that the modulus is NOT simply a, but abs(a). If a were negative, then would you expect the modulus to be negative? Of course not.
And as far as the phase angle goes, it is not quite as simple as you have shown it.
ans = 
Yes, I know you need not believe me. But that phase angle is a function of a also. For example, suppose a were 1 or -1?
Z1 = 1*exp(2i)
Z1 = -0.4161 + 0.9093i
Z2 = -1*exp(2i)
Z2 = 0.4161 - 0.9093i
ans = 1×2
2.0000 -1.1416
So we would indeed expect two distinct phase angles for Z1 and Z2.
Your problem lies in your expectations.

Community Treasure Hunt

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

Start Hunting!

Translated by