-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathextract_TD_features.m
70 lines (48 loc) · 1.98 KB
/
extract_TD_features.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function [ features ] = extract_TD_features( sensor )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
for i = 1: 1: 3
for j = 1: 1: 3
for k = 1: 1: (20*2^i)
signal = sensor{i, j}(:, k);
% Max value
tmp{1}{i,j}(1,k) = max(signal);
% Min value
tmp{2}{i,j}(1,k) = min(signal);
% Root-Mean-Square Level (RMS)
tmp{3}{i,j}(1,k) = rms(signal);
% Mean
tmp{4}{i,j}(1,k) = mean(signal);
% Variance
tmp{5}{i,j}(1,k) = var(signal);
% Standard deviation
tmp{6}{i,j}(1,k) = std(signal);
% Peak to peak
tmp{7}{i,j}(1,k) = peak2peak(signal);
% Peak to RMS
tmp{8}{i,j}(1,k) = peak2rms(signal);
% Mean of upper and lower envelopes
[yh,yl] = envelope(signal);
tmp{9}{i,j}(1,k) = mean(yh);
tmp{10}{i,j}(1,k) = mean(yl);
% Similarity of signal patterns
tmp{11}{i,j}(1,k) = dtw(signal(1:1000/2^(i-1)), ...
signal(1000/2^(i-1)+1:2000/2^(i-1)));
% Compute percentiles
p25 = prctile(max(signal), 25);
p75 = prctile(max(signal), 75);
mag = signal;
% Compute squared sum of data below certain percentile (25, 75)
sumsq25 = sum(mag(mag < p25) .^ 2);
sumsq75 = sum(mag(mag < p75) .^ 2);
% Sum amplitude signal below 25%
tmp{12}{i,j}(1,k) = sumsq25;
% Sum amplitude signal below 75%
tmp{13}{i,j}(1,k) = sumsq75;
% Root-Sum-of-Squares of the signal
tmp{14}{i,j}(1,k) = rssq(signal);
end;
end;
end;
features = tmp;
end