function [AEF, CORRMAT] = arrange(A,AE,N,L); CORRMAT = zeros(L,L); %% Looking for the column of AE with largest correlation for A %% 1/ Fill the matrix of values showing all correlations between columnsof A and AE %% 2/ Go through this matrix for each column of A and compare with maxcorr to find out the corresponding column for AE %% 3/ Calculate th corresponding c, the complex scalar value %% 4/ Apply c to the corresponding column of AE and put it in AEF at the right place (column of A) %% 5/ Reduce the CORRMAT matrix by putting 0 for the corresponding column of AE; AEF = zeros(N,L); maxcorr = 0; for k=1:L, for j=1:L, CORRMAT(k,j) = abs( (A(:,k)' * AE(:,j)) / sqrt(AE(:,j)' * AE(:,j)) ); end; end; for k=1:L, for j=1:L, if CORRMAT(j,k) > maxcorr idx_m = j; end; c = (AE(:,idx_m)' * A(:,k)) / (AE(:,idx_m)' * AE(:,idx_m)); AEF(:,k) = AE(:,idx_m) .* c; CORRMAT(:,k) = 0; end; end;