Matlab commands for real part - real(x)
Matlab commands for imaginary part - imag(x)
Example:
>> x = 1 + 2j
x =
1.0000 + 2.0000i
>> real(x)
ans =
1
>> imag(x)
ans =
2
>>
To multiply x with an imaginary unit i or -i, simply swap the real part with the imaginary part and add a negative sign.
Example:
x = 1 + 2j
mult_pos_j(x)
mult_neg_j(x)
function result = mult_pos_j(x)
% x = a + bj
% x(j) = aj - b = -b + aj
result = -imag(x) + real(x)*j;
end
function result = mult_neg_j(x)
% x = a + bj
% x(-j) = -aj + b = b - aj
result = imag(x) - real(x)*j;
end
Result:
x =
1.0000 + 2.0000i
ans =
-2.0000 + 1.0000i
ans =
2.0000 - 1.0000i
Related Information:
Complex numbers - simple calculations (StudySwift - iOS)
沒有留言:
張貼留言