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

47 ビュー (過去 30 日間)
Rabih Sokhen
Rabih Sokhen 2021 年 12 月 7 日
編集済み: John D'Errico 2021 年 12 月 7 日
clear all
clc
syms a b c
z=a*exp(i*b*c)
arg=angle(z)
mod=abs(z)
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

回答 (1 件)

John D'Errico
John D'Errico 2021 年 12 月 7 日
編集済み: John D'Errico 2021 年 12 月 7 日
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);
abs(z)
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.
angle(z)
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
[angle(Z1),angle(Z2)]
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