Home > classes > @pole > resp.m

resp

PURPOSE ^

RESP returns the complex response of the pole object.

SYNOPSIS ^

function [f,r] = resp(varargin)

DESCRIPTION ^

 RESP returns the complex response of the pole object.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: RESP returns the complex response of the pole object.

 CALL:        [f,r] = resp(p, f);          % compute response for vector f
              [f,r] = resp(p, f1, f2, nf); % compute response from f1 to f2 in nf
                                             steps.
              [f,r] = resp(p, pl);         % compute response from parameter list.

 REMARK:      This is just a helper function. This function should only be
              called from class functions.

 PARAMETERS:  'f'     - a vector of frequencies to evaluate at
            or
              'f1'    - start frequency
              'f2'    - stop frequency
              'nf'    - number of evaluation frequencies
              'scale' - spacing of frequencies: 'lin' or 'log'

 VERSION:     $Id: resp.m,v 1.5 2008/01/11 14:04:43 ingo Exp $

 HISTORY:     03-04-2007 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [f,r] = resp(varargin)
0002 % RESP returns the complex response of the pole object.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: RESP returns the complex response of the pole object.
0007 %
0008 % CALL:        [f,r] = resp(p, f);          % compute response for vector f
0009 %              [f,r] = resp(p, f1, f2, nf); % compute response from f1 to f2 in nf
0010 %                                             steps.
0011 %              [f,r] = resp(p, pl);         % compute response from parameter list.
0012 %
0013 % REMARK:      This is just a helper function. This function should only be
0014 %              called from class functions.
0015 %
0016 % PARAMETERS:  'f'     - a vector of frequencies to evaluate at
0017 %            or
0018 %              'f1'    - start frequency
0019 %              'f2'    - stop frequency
0020 %              'nf'    - number of evaluation frequencies
0021 %              'scale' - spacing of frequencies: 'lin' or 'log'
0022 %
0023 % VERSION:     $Id: resp.m,v 1.5 2008/01/11 14:04:43 ingo Exp $
0024 %
0025 % HISTORY:     03-04-2007 M Hewitson
0026 %                 Creation
0027 %
0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0029 
0030 VERSION = '$Id: resp.m,v 1.5 2008/01/11 14:04:43 ingo Exp $';
0031 
0032 % Check if this is a call for parameters or for the cvs-version number
0033 if nargin == 2
0034   if isa(varargin{1}, 'pole') && ischar(varargin{2})
0035     in = char(varargin{2});
0036     if strcmp(in, 'Params')
0037       f = plist();
0038       return
0039     elseif strcmp(in, 'Version')
0040       f = VERSION;
0041       return
0042     end
0043   end
0044 end
0045 
0046 if nargin < 1
0047   error('### incorrect number of inputs.')
0048 end
0049 
0050 % look at inputs
0051 p = varargin{1};
0052 if ~isa(p, 'pole')
0053   error('### first argument should be a pole object.');
0054 end
0055 % Now look at the pole
0056 f0 = get(p, 'f');
0057 Q  = get(p, 'q');
0058 
0059 % check inputs
0060 if nargin == 1
0061 
0062   f = linspace(f0/10, 10*f0, 1000);
0063 
0064 elseif nargin == 2
0065   if isa(varargin{2}, 'plist')
0066     pl = varargin{2};
0067     f  = find(pl, 'f');
0068     f1 = find(pl, 'f1');
0069     f2 = find(pl, 'f2');
0070     nf = find(pl, 'nf');
0071     scale = find(pl, 'scale');
0072 
0073     if ~isempty(f)
0074       % nothing
0075     elseif ~isempty(f1) && ~isempty(f2) && ~isempty(nf)
0076       if isempty(scale) || strcmp(scale, 'lin')
0077         f = linspace(f1, f2, nf);
0078       elseif strcmp(scale, 'log')
0079         f = logspace(log10(f1), log10(f2), nf);
0080       else
0081         error('### unknown scale option for pole response.');
0082       end
0083     else
0084       error('### unknown parameter list for pole response.');
0085     end
0086 
0087   else
0088     f = varargin{2};
0089   end
0090 elseif nargin == 4
0091   f1 = varargin{2};
0092   f2 = varargin{3};
0093   nf = varargin{4};
0094   f  = linspace(f1, f2, nf);
0095 else
0096   error('### incorrect number of inputs.');
0097 end
0098 
0099 
0100 if Q>0.5
0101   re = 1 - (f.^2./f0^2);
0102   im = f ./ (f0*Q);
0103   r = 1./complex(re, im);
0104 else
0105   re = 1;
0106   im = f./f0;
0107   r = 1./complex(re, im);
0108 end
0109 
0110 
0111 % END

Generated on Tue 22-Jan-2008 10:39:13 by m2html © 2003