Mercurial > hg > lots
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/l1overl2.m Wed Jun 15 11:26:03 2011 +0100 @@ -0,0 +1,33 @@ +function z = l1overl2(X) +%L1OVERL2 ratio between the l1 and the l2 norms. +% +% z = l1overl2(X) +% +% computes the ratio between the l1 and the l2 norm of the input X. If +% input is a matrix, the norms are calculated along the columns and a mean +% value is returned. If the input is a cell, the norms are calculated +% independently for each cell entry and a mean value is returned. +% +% ----------------------------------------------------------- % +% Daniele Barchiesi, daniele.barchiesi@eecs.qmul.ac.uk % +% Centre for Digital Music, Queen Mary University of London % +% Apr. 2011 % +% ----------------------------------------------------------- % +if iscell(X) + nCols = length(X); + z = zeros(nCols,1); + for i=1:nCols + z(i) = norm(X{:,i},1)/norm(X{:,i},2); + end +else + nCols = size(X,2); + z = zeros(nCols,1); + for i=1:nCols + z(i) = norm(X(:,i),1)/norm(X(:,i),2); + end +end + +z(isnan(z)) = []; +z = mean(z); + +%EOF \ No newline at end of file