annotate util/ksvd utils/remove_dc.m @ 170:68fb71aa5339 danieleb

Added dictionary decorrelation functions and test script for Letters paper.
author Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk>
date Thu, 06 Oct 2011 14:33:41 +0100
parents c3eca463202d
children
rev   line source
idamnjanovic@70 1 function [y,dc] = remove_dc(x,columns)
idamnjanovic@70 2 %REMOVE_DC Remove DC channel from signals.
idamnjanovic@70 3 % [Y,DC] = REMOVE_DC(X) removes the DC channel (i.e. the mean) from the
idamnjanovic@70 4 % specified (possibly multi-dimensional) signal X. Y is the DC-free
idamnjanovic@70 5 % signal and is the same size as X. DC is a scalar containing the mean of
idamnjanovic@70 6 % the signal X.
idamnjanovic@70 7 %
idamnjanovic@70 8 % [Y,DC] = REMOVE_DC(X,'columns') where X is a 2D matrix, treats the
idamnjanovic@70 9 % columns of X as a set of 1D signals, removing the DC channel from each
idamnjanovic@70 10 % one individually. Y is the same size as X and contains the DC-free
idamnjanovic@70 11 % signals. DC is a row vector of length size(X,2) containing the means of
idamnjanovic@70 12 % the signals in X.
idamnjanovic@70 13 %
idamnjanovic@70 14 % See also ADD_DC.
idamnjanovic@70 15
idamnjanovic@70 16
idamnjanovic@70 17 if (nargin==2 && strcmpi(columns,'columns')), columns = 1;
idamnjanovic@70 18 else columns = 0;
idamnjanovic@70 19 end
idamnjanovic@70 20
idamnjanovic@70 21 if (columns)
idamnjanovic@70 22 dc = mean(x);
idamnjanovic@70 23 y = addtocols(x,-dc);
idamnjanovic@70 24 else
idamnjanovic@70 25 if (ndims(x)==2) % temporary, will remove in future
idamnjanovic@70 26 warning('Treating 2D matrix X as a single signal and not each column individually');
idamnjanovic@70 27 end
idamnjanovic@70 28 dc = mean(x(:));
idamnjanovic@70 29 y = x-dc;
idamnjanovic@70 30 end
idamnjanovic@70 31