TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
notchpeakargchk.m
Go to the documentation of this file.
1 %> @file notchpeakargchk.m
2 %> @brief NOTCHPEAKARGCHK Validates the inputs for the IIRNOTCH and IIRPEAK
3 %> functions.
4 function [Ab, msg] = notchpeakargchk(Wo, BW, opts)
5 % Author(s): P. Pacheco
6 % Copyright 1999-2002 The MathWorks, Inc.
7 % $Revision: 1.2 $ $Date: 2001/07/06 17:42:26 $
8 
9 % Define default values.
10 Ab = abs(10*log10(.5)); % 3-dB width
11 msg = '';
12 
13 % Check Wo and BW for notch/peak filters.
14 msg = freq_n_bandwidth(Wo, BW);
15 if msg
16  return
17 end
18 
19 % Parse and validate optional input args.
20 [Ab, msg] = parseoptions(Ab, opts);
21 if msg
22  return
23 end
24 
25 
26 
27 function msg = freq_n_bandwidth(Wo, BW)
28 % Check Wo and BW for notch/peak filters.
29 
30 msg = '';
31 % Validate frequency cutoff and bandwidth.
32 if (Wo <= 0) || (Wo >= 1)
33  msg = 'The frequency Wo must be within 0 and 1.';
34  return;
35 end
36 
37 if (BW <= 0) || (BW >= 1)
38  msg = 'The bandwidth BW must be within 0 and 1.';
39  return;
40 end
41 
42 
43 
44 function [Ab, msg] = parseoptions(Ab, opts)
45 % Parse the optional input arguments.
46 
47 msg = '';
48 if ~isempty(opts)
49  [Ab, msg] = checkAtten(opts{1});
50 end
51 
52 
53 
54 function [Ab, msg] = checkAtten(option)
55 % Determine if input argument is a scalar numeric value.
56 
57 % Initialize output args.
58 Ab = [];
59 msg = '';
60 if isnumeric(option) && all(size(option)==1) % Make sure it's a scalar
61  Ab = abs(option); % Allow - or + values
62 else
63  msg = 'Level of decibels specified by Ab must be a numeric scalar.';
64 end
65 
66 % [EOF]
notchpeakargchk
function notchpeakargchk(in Wo, in BW, in opts)
parseoptions
function parseoptions(in Ab, in opts)
checkAtten
function checkAtten(in option)
freq_n_bandwidth
function freq_n_bandwidth(in Wo, in BW)