Calculate the deltas of a sequence

Status
Not open for further replies.

Biruntha

Junior Member level 1
Joined
May 26, 2015
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
Jaffna, Srilanka
Activity points
102
Here is the code i found to Calculate the deltas of a sequence. Can anyone tell what is the purpose of doing this?
explain the code?

Code:
function d = deltas(x, w)
% D = deltas(X,W)  Calculate the deltas (derivatives) of a sequence
%    Use a W-point window (W odd, default 9) to calculate deltas using a
%    simple linear slope.
% calculate delta features over a limited window, just like feacalc/calc_deltas etc.

if nargin < 2
    w = 9;
end
[nr,nc] = size(x);
% Define window shape
hlen = floor(w/2);
w = 2*hlen + 1;
win = hlen:-1:-hlen;
% pad data by repeating first and last columns
xx = [repmat(x(:,1),1,hlen),x,repmat(x(:,end),1,hlen)];
% Apply the delta filter
d = filter(win, 1, xx, [], 2);  % filter along dim 2 (rows)
% Trim edges
d = d(:,2*hlen + [1:nc]);
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…