Sign of imaginary value changes after converting to array
조회 수: 5 (최근 30일)
이전 댓글 표시
When I calculate these complex numbers, they have positive imaginary components. However, in the complex array z, all of the nonzero imaginary components become negative.
I can't find this behavior in the documentation so I do not understand what is going on.
a = 2 + 1j;
b = 1 + 3j;
% a)
z1 = a*b;
% b)
z2 = b*conj(b);
% c)
z3 = a^3;
% d)
z4 = b/a;
z = [z1; z2; z3; z4];
댓글 수: 0
채택된 답변
Steven Lord
2021년 2월 11일
My guess is that you accidentally used the conjugate transpose operator (') instead of the non-conjugate transpose operator (.') somewhere in your code.
v = (1+1i)*(1:5);
imag(v)
x = v.';
imag(x) % non-conjugate
y = v'; % conjugate
imag(y)
추가 답변 (1개)
James Tursa
2021년 2월 11일
Here is what I get:
>> a = 2 + 1j;
>> b = 1 + 3j;
>> z1 = a*b
z1 =
-1.0000 + 7.0000i
>> z2 = b*conj(b)
z2 =
10
>> z3 = a^3
z3 =
2.0000 +11.0000i
>> z4 = b/a
z4 =
1.0000 + 1.0000i
>> z = [z1; z2; z3; z4]
z =
-1.0000 + 7.0000i
10.0000 + 0.0000i
2.0000 +11.0000i
1.0000 + 1.0000i
Try clearing your workspace and starting from scratch. Maybe you inadvertently used different variables?
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!