-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_ind_eval.m
48 lines (41 loc) · 1.34 KB
/
get_ind_eval.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
%
% This file is part of pichim's controller tuning framework.
%
% This sofware is free. You can redistribute this software
% and/or modify this software under the terms of the GNU General
% Public License as published by the Free Software Foundation,
% either version 3 of the License, or (at your option) any later
% version.
%
% This software is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
%
% See the GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public
% License along with this software.
%
% If not, see <http:%www.gnu.org/licenses/>.
%
%%
function ind_eval = get_ind_eval(sinarg, data, threshold)
if nargin == 2
threshold = 500;
end
Ndata = size(sinarg, 1);
ind_eval_candidate = sinarg > 0;
signal = zeros(Ndata, 1);
signal(ind_eval_candidate) = 1;
dsignal = [0; diff(signal)];
ind_eval_start = find(dsignal > 0.9);
ind_eval_end = find(dsignal < -0.9) - 1;
Neval = size(ind_eval_start, 1);
ind_eval = false(Ndata, 1);
for i = 1:Neval
ind_verify = ind_eval_start(i):ind_eval_end(i);
if var(data(ind_verify)) > threshold
ind_eval(ind_verify) = true;
end
end
end