Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matlab accumarray with complex numbers

I don't understand accumarray behaviour when passed complex numbers. I expect accumarray([1 1]', [1i 2i]') to behave like sum([1i 2i]) (for this particuar case).

It however returns 0.0000 - 3.0000i instead of 0.0000 + 3.0000i.

like image 942
Mark Loyman Avatar asked Dec 31 '25 21:12

Mark Loyman


1 Answers

You mixed up your operators. ' is the complex conjugate transpose. Use .' to do a regular transpose. So you're doing sum([-1i; -2i]) which is indeed -3i. Calling accumarray([1 1].', [1i 2i].'), mind the dots, gives 0.0000 + 3.0000i.

See also Why is complex conjugate transpose the default in Matlab

like image 179
Adriaan Avatar answered Jan 02 '26 17:01

Adriaan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!