-
Notifications
You must be signed in to change notification settings - Fork 1
/
sim_real_data.m
61 lines (50 loc) · 1.32 KB
/
sim_real_data.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
function sim_real_data(ANN, rawdata, start, stop)
% Test the model with real data
%
% A Vlissidis
matched = [10, 20, 30];
%matched = 5:5:30;
fs = 1e5;
fc = [200 5000];
figure;
for i = 2:6
subplot(5, 1, i-1);
plot(rawdata(start:5:stop, 1),rawdata(start:5:stop, i));
end
xlabel('Time (s)');
% Apply electro shifts
data = electroshift(rawdata(start:stop, :), [0.7208 1.2092 0.8901 1.1302] * 1e-3, 8);
data = data(1:5:end, :);
InputSequence = data(:, 2:end)';
% Filter the data to remove Red Noise
%medFilt = dsp.MedianFilter(2);
%InputSequence = medFilt(InputSequence);
% [b, a] = butter(3, fc/(fs/2), 'bandpass');
% [channels, ~] = size(InputSequence);
% for i = 1:channels
% InputSequence(i, :) = filter(b, a, InputSequence(i, :));
% end
% Plot the filtered input channels
% figure;
% for i = 2:6
% subplot(5, 1, i-1);
% plot(rawdata(start:5:stop, 1),InputSequence(i-1, :));
% end
% xlabel('Time (s)');
NormInput = AgcSim(InputSequence);
InputCellArray = con2seq(NormInput);
figure;
NumAnns = numel(ANN);
buf = zeros(1, NumAnns);
for i = 1:NumAnns
net = ANN(i).net;
OutputCellArray = sim(net, InputCellArray);
AnnOutput = cell2mat(OutputCellArray);
buf(i) = max(AnnOutput);
subplot(numel(ANN), 1, i);
plot(rawdata(start:5:stop, 1), AnnOutput);
end
xlabel('Time (s)')
[~, idx] = max(buf);
matched(idx)
end