File: check_frequency.m

package info (click to toggle)
openems 0.0.35%2Bgit20190103.6a75e98%2Bdfsg.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 8,424 kB
  • sloc: cpp: 40,407; python: 2,028; yacc: 580; makefile: 458; lex: 350; sh: 176; ruby: 19
file content (31 lines) | stat: -rw-r--r-- 821 bytes parent folder | download | duplicates (3)
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
function pass = check_frequency( f, val, f_upper, f_lower, rel_amplitude, type )

pass = true;
max1 = max(val);

if numel(f_upper) ~= numel(f_lower)
    error 'inconsistant vectors'
end

for n=1:numel(f_upper)
    f1 = f_lower(n);
    f2 = f_upper(n);
    f1_idx = interp1( f, 1:numel(f), f1, 'nearest' );
%    if f(f1_idx) < f1, f1_idx = f1_idx + 1; end
    f2_idx = interp1( f, 1:numel(f), f2, 'nearest' );
%    if f(f2_idx) > f2, f2_idx = f2_idx - 1; end

    if strcmp( type, 'inside' )
        if max( val(f1_idx:f2_idx) ) < max1 * rel_amplitude
            pass = false;
            return
        end
    elseif strcmp( type, 'outside' )
        if max( val(f1_idx:f2_idx) ) > max1 * rel_amplitude
            pass = false;
            return
        end
    else
        error 'unsupported operation'
    end
end