Performing an Operation on a Matrix Using Complex Numbers
Show older comments
I have a matrix with the operation perfomed as:
a = rand(10,10);
a_x = @(x) sum((x-a)./(x+a),'all');
aa = arrayfun(a_x,a);
I want the operation for each pair to be performed in complex format. For example for one pair of the matrix ( a(1) & a(2) ) points, it will be like:
complex(a(1),-a(2)) / complex(a(1),a(2)); %% a(1) - a(2)i / a(1) + a(2)i
Which will give me:
ans =
-0.0313 - 0.9995i
I want this operation (sum of all the relations for each point) to be performed for all the matrix components (may original matrix is 81*81).
2 Comments
Walter Roberson
on 7 Jan 2022
To confirm, you want
complex(a(I,J),-a(K,L)) / complex(a(I,J),a(K,L));
for all I, J, and K, L? Including or excluding K,L = I,J ?
So you want (81 x 81) x (81 x 81) size output ?
MarshallSc
on 7 Jan 2022
Accepted Answer
More Answers (1)
Matt J
on 7 Jan 2022
sz=size(a);
C=2*atan(a(:),a(:).');
result=reshape( exp(1j*C), [sz,sz]);
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!