comparison util/ksvd utils/remove_dc.m @ 70:c3eca463202d

(none)
author idamnjanovic
date Wed, 16 Mar 2011 14:16:57 +0000
parents
children
comparison
equal deleted inserted replaced
69:5f1f436057ca 70:c3eca463202d
1 function [y,dc] = remove_dc(x,columns)
2 %REMOVE_DC Remove DC channel from signals.
3 % [Y,DC] = REMOVE_DC(X) removes the DC channel (i.e. the mean) from the
4 % specified (possibly multi-dimensional) signal X. Y is the DC-free
5 % signal and is the same size as X. DC is a scalar containing the mean of
6 % the signal X.
7 %
8 % [Y,DC] = REMOVE_DC(X,'columns') where X is a 2D matrix, treats the
9 % columns of X as a set of 1D signals, removing the DC channel from each
10 % one individually. Y is the same size as X and contains the DC-free
11 % signals. DC is a row vector of length size(X,2) containing the means of
12 % the signals in X.
13 %
14 % See also ADD_DC.
15
16
17 if (nargin==2 && strcmpi(columns,'columns')), columns = 1;
18 else columns = 0;
19 end
20
21 if (columns)
22 dc = mean(x);
23 y = addtocols(x,-dc);
24 else
25 if (ndims(x)==2) % temporary, will remove in future
26 warning('Treating 2D matrix X as a single signal and not each column individually');
27 end
28 dc = mean(x(:));
29 y = x-dc;
30 end
31