-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrainingSetBuilder_SvD.m
More file actions
71 lines (57 loc) · 2.36 KB
/
Copy pathtrainingSetBuilder_SvD.m
File metadata and controls
71 lines (57 loc) · 2.36 KB
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
70
71
source_folder = 'restructured_dataset';
subfolders = {'dati_buoni'; 'dati_cattivi'};
target_folder = 'features_dataset';
orientations = ['H', 'V'];
dynamicCases = ['I', 'U', 'P'];
root = pwd;
for subfolder_idx = 1 : size(subfolders, 1)
subfolder = subfolders(subfolder_idx);
curr_source_folder = fullfile(root, source_folder, subfolder);
cd(curr_source_folder{1});
load('data.mat')
for orientation = orientations
table = struct();
table.power_std = zeros(60,1);
table.power_mean = zeros(60,1);
table.power_median = zeros(60,1);
table.phase_std = zeros(60,1);
table.phase_mean = zeros(60,1);
table.phase_median = zeros(60,1);
table.out_isStatic = zeros(60,1);
%Static case
if orientation == 'H'
idx = 1:30;
else
idx = 31:60;
end
powerFeatures = extractFeatures(data.static.power(idx));
phaseFeatures = extractFeatures(data.static.phase(idx));
idx = 1:30;
table.power_std(idx) = powerFeatures.std;
table.power_mean(idx) = powerFeatures.mean;
table.power_median(idx) = powerFeatures.median;
table.phase_std(idx) = phaseFeatures.std;
table.phase_mean(idx) = phaseFeatures.mean;
table.phase_median(idx) = phaseFeatures.median;
table.out_isStatic(idx) = 1;
%Dynamic case
baseIdx = 31;
for dynamicCase = dynamicCases
powerFeatures = extractFeatures(data.dynamic.(orientation).(dynamicCase).power);
phaseFeatures = extractFeatures(data.dynamic.(orientation).(dynamicCase).phase);
idx = baseIdx : baseIdx + 9;
table.power_std(idx) = powerFeatures.std;
table.power_mean(idx) = powerFeatures.mean;
table.power_median(idx) = powerFeatures.median;
table.phase_std(idx) = phaseFeatures.std;
table.phase_mean(idx) = phaseFeatures.mean;
table.phase_median(idx) = phaseFeatures.median;
table.out_isStatic(idx) = 0;
baseIdx = baseIdx + 10;
end
dest_folder = fullfile(root, target_folder, subfolder);
mkdir(dest_folder{1});
save(fullfile(dest_folder{1}, ['trainingSet_SvD_', orientation, '.mat']), 'table');
end
cd(root);
end