[422372]: / functions / sigprocfunc / eyelike.m

Download this file

29 lines (25 with data), 745 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function [eyelikeres, S, P]= eyelike(E)
% EYELIKE - calculate a permutation matrix P and a scaling (diagonal) maxtrix S
% such that S*P*E is eyelike (so permutation acts on the rows of E).
% E must be a square matrix.
% Usage:
% >> [eyelike, S, P] = eyelike(E);
%
% Author: Benjamin Blankertz (blanker@first.gmd.de) 3/2/00
[N, M]= size(E);
if N ~= M
fprintf('eyeLike(): input matrix must be square.\n');
return
end
R= E./repmat(sum(abs(E),2),1,N);
Rabs= abs(R);
P= zeros(N);
for n=1:N
[so, si]= sort(-Rabs(:));
[chosenV, chosenH]= ind2sub([N N], si(1));
P(chosenH,chosenV)= 1;
Rabs(chosenV,:)= repmat(-inf, 1, N);
Rabs(:,chosenH)= repmat(-inf, N, 1);
end
S= diag(1./diag(P*E));
eyelikeres= S*P*E;