1function pass = check_frequency( f, val, f_upper, f_lower, rel_amplitude, type ) 2 3pass = true; 4max1 = max(val); 5 6if numel(f_upper) ~= numel(f_lower) 7 error 'inconsistant vectors' 8end 9 10for n=1:numel(f_upper) 11 f1 = f_lower(n); 12 f2 = f_upper(n); 13 f1_idx = interp1( f, 1:numel(f), f1, 'nearest' ); 14% if f(f1_idx) < f1, f1_idx = f1_idx + 1; end 15 f2_idx = interp1( f, 1:numel(f), f2, 'nearest' ); 16% if f(f2_idx) > f2, f2_idx = f2_idx - 1; end 17 18 if strcmp( type, 'inside' ) 19 if max( val(f1_idx:f2_idx) ) < max1 * rel_amplitude 20 pass = false; 21 return 22 end 23 elseif strcmp( type, 'outside' ) 24 if max( val(f1_idx:f2_idx) ) > max1 * rel_amplitude 25 pass = false; 26 return 27 end 28 else 29 error 'unsupported operation' 30 end 31end 32