comparison l1overl2.m @ 3:ee2a86d7ec07

Added support functions
author danieleb@code.soundsoftware.ac.uk
date Wed, 15 Jun 2011 11:26:03 +0100
parents
children e23a23349e31
comparison
equal deleted inserted replaced
2:e124001d2437 3:ee2a86d7ec07
1 function z = l1overl2(X)
2 %L1OVERL2 ratio between the l1 and the l2 norms.
3 %
4 % z = l1overl2(X)
5 %
6 % computes the ratio between the l1 and the l2 norm of the input X. If
7 % input is a matrix, the norms are calculated along the columns and a mean
8 % value is returned. If the input is a cell, the norms are calculated
9 % independently for each cell entry and a mean value is returned.
10 %
11 % ----------------------------------------------------------- %
12 % Daniele Barchiesi, daniele.barchiesi@eecs.qmul.ac.uk %
13 % Centre for Digital Music, Queen Mary University of London %
14 % Apr. 2011 %
15 % ----------------------------------------------------------- %
16 if iscell(X)
17 nCols = length(X);
18 z = zeros(nCols,1);
19 for i=1:nCols
20 z(i) = norm(X{:,i},1)/norm(X{:,i},2);
21 end
22 else
23 nCols = size(X,2);
24 z = zeros(nCols,1);
25 for i=1:nCols
26 z(i) = norm(X(:,i),1)/norm(X(:,i),2);
27 end
28 end
29
30 z(isnan(z)) = [];
31 z = mean(z);
32
33 %EOF