Correlation Function giving the same output for different inputs

2 visualizaciones (últimos 30 días)
Hey everyone! I'm struggling with implementing a correlation metric that compares two 3D complex matrices and scales their correlation to 0-1. 0 meaning no correlation and 1 meaning perfect correlation.
It has two variations (shown in the screenshot below).
The first variation is giving accurate results but the second one is giving the same results even if I change the inputs.
Y_1 and Y_2 are complex 3D matrices (e.g. 3x3x3) and share the same dimensions.
CSF (32.1) is working as expected according to the way I programmed it as follows. I have also attached a screenshot of the equation.
For inputs you can use:
rng(10)
Y_1=rand(3,3,3)+1j;
Y_2=rand(3,3,3)+pi*1j;
CSF MATLAB Code
[~,CSF2DMAT,~] = funcCSF(Y_1,Y_2)
CSF2DMAT = 3×3
0.6598 0.6067 0.6199 0.6332 0.6201 0.6517 0.6699 0.6406 0.6110
The issue is with CSAC (32.2), the code is given below.
CSAC MATLAB Code
[~,CSAC2DMAT,~] = funcCSAC(Y_1,Y_2)
CSAC2DMAT = 3×3
1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
function [CSF,CSF2DMAT,OverallCSF] = funcCSF(Y_1,Y_2)
numerator = 2*(abs((conj(Y_1).*Y_2)));
denominator = (Y_1 .* conj(Y_1)) + (Y_2 .* conj(Y_2));
CSF = numerator ./ denominator;
OverallCSF=mean(CSF,'all');
CSF2DMAT=mean(CSF,3);
end
function [CSAC,CSAC2DMAT,OverallCSAC] = funcCSAC(Y_1,Y_2)
numerator = ( abs( (conj(Y_1).*Y_2) ) ).^2;
denominator = ( Y_1 .* conj(Y_1) ) .* ( Y_2 .* conj(Y_2) );
CSAC = numerator ./ denominator;
OverallCSAC = mean(CSAC, 'all');
CSAC2DMAT=mean(CSAC, 3);
end
Even if I give it two completely random inputs it gives me a perfect correlation of 1. Am I implementing the equations shown below correctly? My observation for CSAC is that the numerator and denominator are almost equal which isn't the case for CSF.
If anyone can please help me out I'll be really grateful. Thank you!
PS: (.)^H is the Hermitian complex transpose.

Respuestas (1)

Daniel Vieira
Daniel Vieira el 8 de Feb. de 2024
this fomula for CSAC results 1 for any complex numbers H1 and H2. It may be wrong, you should check the same formula from other source.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by