changeset 3:ee2a86d7ec07

Added support functions
author danieleb@code.soundsoftware.ac.uk
date Wed, 15 Jun 2011 11:26:03 +0100
parents e124001d2437
children e23a23349e31
files .hgignore l1overl2.m lappedorthobasis.m mag2db.m normcol.m
diffstat 5 files changed, 52 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Wed Jun 15 11:26:03 2011 +0100
@@ -0,0 +1,1 @@
+lappedorthobasis\.m~
--- /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
--- a/lappedorthobasis.m	Tue Jun 14 15:52:47 2011 +0100
+++ b/lappedorthobasis.m	Wed Jun 15 11:26:03 2011 +0100
@@ -77,7 +77,7 @@
 %last frame
 g = lappedwindow(wLength(end),tailLength,tailFunc,'last');
 if strcmpi(orthobasis,'mdct')
-    orthoMat = dctmatrix(wLength(end),[],'I');
+    orthoMat = dcti(eye(wLength(end)),'I');
 else
     orthoMat = basisFun(eye(wLength(end)));
 end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mag2db.m	Wed Jun 15 11:26:03 2011 +0100
@@ -0,0 +1,2 @@
+function y = mag2db(x)
+y = 20*log10(x);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/normcol.m	Wed Jun 15 11:26:03 2011 +0100
@@ -0,0 +1,15 @@
+function [x n] = normcol(x)
+%NORMCOL normalise the columns to unit length
+%
+% [x n] = normcol(x)
+%
+% normalises the columns of the input matrix x and returns a vector n
+% containing the initial norm of the columns.
+%
+% ----------------------------------------------------------- %
+%  Daniele Barchiesi, daniele.barchiesi@eecs.qmul.ac.uk       %
+%  Centre for Digital Music, Queen Mary University of London  %
+%  Apr. 2011                                                  %
+% ----------------------------------------------------------- %
+n = sqrt(sum(conj(x).*x,1));
+x = x*diag(1./n);
\ No newline at end of file