forked from Ralireza/robotic-cyber-attack-detection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_all_feature.m
45 lines (34 loc) · 1.49 KB
/
get_all_feature.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
function [ wa,a1,a2,wa_test,a1_test,a2_test ] = get_all_feature()
% initialize feature vectors
wa_feature_train=zeros(1,11);
wa_feature_test=zeros(1,11);
a1_feature_train=zeros(1,11);
a1_feature_test=zeros(1,11);
a2_feature_train=zeros(1,11);
a2_feature_test=zeros(1,11);
% without attack features train and label 0
for i=1:8
wa_feature_train=[wa_feature_train;extract_feature(strcat('./DATA/without-attack/WA_',int2str(i),'.bag'),0)];
end
% attack 1 features train and label 1
for j=1:6
a1_feature_train=[a1_feature_train;extract_feature(strcat('./DATA/attack-1/a1-',int2str(j),'.bag'),1)];
end
% attack 2 features train and label 2
for z=1:3
a2_feature_train=[a2_feature_train;extract_feature(strcat('./DATA/attack-2/a2-',int2str(z),'.bag'),2)];
end
% build tests
for k=1:2
wa_feature_test=[wa_feature_test;extract_feature(strcat('./DATA/without-attack/WA-V-',int2str(k),'.bag'),0)];
a1_feature_test=[a1_feature_test;extract_feature(strcat('./DATA/attack-1/A1-V-',int2str(k),'.bag'),1)];
a2_feature_test=[a2_feature_test;extract_feature(strcat('./DATA/attack-2/A2-V-',int2str(k),'.bag'),2)];
end
% delete first row that contain zeros
wa=wa_feature_train(2:end,:);
a1=a1_feature_train(2:end,:);
a2=a2_feature_train(2:end,:);
wa_test=wa_feature_test(2:end,:);
a1_test=a1_feature_test(2:end,:);
a2_test=a2_feature_test(2:end,:);
end