-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathnormalize_DC_AGC.m
28 lines (24 loc) · 1.21 KB
/
normalize_DC_AGC.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function y = normalize_DC_AGC(x,Parameters)
%NORMALIZE_DC_AGC Remove DC and normalize power
% Ths function removes the residual DC and gain from the input signals,
% treated separately.
%
% It requires movmean and movstd, therefore MATLAB R2016a+ is needed
%
% INPUTS:
% x := Array of signals (column vectors) to process
% Parameters := Parameter structure (see GET_DEFAULT_PARAMS)
%
% OUTPUTS
% y := Array of processed signals (column vectors)
% Mar. 2016 - Dario Pilori <[email protected]>
%% Retrieve parameters from stucture
kDC = Parameters.kDC; % memory of DC-block (samples)
kAGC = Parameters.kAGC; % memory of AGC (samples)
%% Check input parameters
validateattributes(x,{'double'},{'2d'},'','x',1);
validateattributes(kDC,{'numeric'},{'scalar','positive','integer'},'Parameters','kDC',2);
validateattributes(kAGC,{'numeric'},{'scalar','positive','integer'},'Parameters','kAGC',2);
%% Normalize DC and AGC
x = x-movmean(x,kDC,1); % remove DC
y = x./movstd(x,kAGC,1); % AGC