I have a complex number z = 5+3j, how do I find the phase of z, complex conjugate of z, and modulus of z?

조회 수: 4 (최근 30일)
For the phase of z, I assume they mean phase angle which is the only result I get when type in complex number phase matlab. And i followed the instructions to get that like this:
z = 5+3j
Ph = angle(z)
fprintf(' %.2f \n;, Ph)
I get a error that z is unrocognized when I defined it as a complex number, any help would be appreicated!

채택된 답변

Steven Lord
Steven Lord 2020년 1월 31일
See the documentation page on Complex Numbers for functions that may be of use when working with complex numbers in MATLAB.
Regarding the three lines of code you posted, when I ran them the error message I received was slightly different.
fprintf(' %.2f \n;, Ph)
Error: Character vector is not terminated properly.
That's caused by a missing quote character in the posted code. When I added it before the comma, it worked.
>> fprintf(' %.2f \n;', Ph)
0.54
If you're seeing a different error please post the exact code you're running and the full and exact text of the error message you receive (all the text displayed in red exactly as it's displayed in the Command Window.)
  댓글 수: 1
Gurinder Punni
Gurinder Punni 2020년 1월 31일
my bad i had actually put the quotes in the code but forgot them here. It seems it was simple error. One of the z's was captial and the other lower case. thanks for the help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by