Home > classes > @pz > resp.m

resp

PURPOSE ^

RESP returns the complex response of the pz object.

SYNOPSIS ^

function [f,r] = resp(varargin)

DESCRIPTION ^

 RESP returns the complex response of the pz object.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: RESP returns the complex response of the pz object. The
              response is computed assuming that object represents a pole.
              If the object represents a zero, just take the inverse of
              the returned response: 1./r.

 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, f1, f2, nf, scale); % compute response from f1 to f2
                                                  % in nf steps using scale ['lin' or 'log'].
              [f,r] = resp(p);             % compute response

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

 M-FILE INFO: Get information about this methods by calling
              >> pz.getInfo('resp')

              Get information about a specified set-plist by calling:
              >> pz.getInfo('resp', 'set')

 VERSION:     $Id: resp.m,v 1.5 2008/09/04 15:29:31 ingo Exp $

 HISTORY:     03-04-2007 Hewitson
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % RESP returns the complex response of the pz object.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: RESP returns the complex response of the pz object. The
0005 %              response is computed assuming that object represents a pole.
0006 %              If the object represents a zero, just take the inverse of
0007 %              the returned response: 1./r.
0008 %
0009 % CALL:        [f,r] = resp(p, f);          % compute response for vector f
0010 %              [f,r] = resp(p, f1, f2, nf); % compute response from f1 to f2
0011 %                                           % in nf steps.
0012 %              [f,r] = resp(p, f1, f2, nf, scale); % compute response from f1 to f2
0013 %                                                  % in nf steps using scale ['lin' or 'log'].
0014 %              [f,r] = resp(p);             % compute response
0015 %
0016 % REMARK:      This is just a helper function. This function should only be
0017 %              called from class functions.
0018 %
0019 % M-FILE INFO: Get information about this methods by calling
0020 %              >> pz.getInfo('resp')
0021 %
0022 %              Get information about a specified set-plist by calling:
0023 %              >> pz.getInfo('resp', 'set')
0024 %
0025 % VERSION:     $Id: resp.m,v 1.5 2008/09/04 15:29:31 ingo Exp $
0026 %
0027 % HISTORY:     03-04-2007 Hewitson
0028 %                 Creation
0029 %
0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0031 
0032 function [f,r] = resp(varargin)
0033 
0034   % Check if this is a call for parameters
0035   if utils.helper.isinfocall(varargin{:})
0036     f = getInfo(varargin{3});
0037     return
0038   end
0039 
0040   %%% Input objects checks
0041   if nargin < 1
0042     error('### incorrect number of inputs.')
0043   end
0044 
0045   %%% look at inputs
0046   p = varargin{1};
0047   if ~isa(p, 'pz')
0048     error('### first argument should be a pz object.');
0049   end
0050 
0051   %%% decide whether we modify the pz-object, or create a new one.
0052   p = copy(p, nargout);
0053 
0054   %%% Now look at the pole
0055   f0 = p.f;
0056   Q  = p.q;
0057 
0058   %%% Define frequency vector
0059   f = [];
0060 
0061   if nargin == 1
0062     f1 = f0/10;
0063     f2 = f0*10;
0064     nf = 1000;
0065     scale = 'lin';
0066   elseif nargin == 2
0067     f = varargin{2};
0068   elseif nargin == 4
0069     f1 = varargin{2};
0070     f2 = varargin{3};
0071     nf = varargin{4};
0072     scale = 'lin';
0073   elseif nargin == 5
0074     f1    = varargin{2};
0075     f2    = varargin{3};
0076     nf    = varargin{4};
0077     scale = varargin{5};
0078   else
0079     error('### incorrect number of inputs.');
0080   end
0081 
0082   %%% Build f if we need it
0083   if isempty(f)
0084     switch scale
0085       case 'lin'
0086         f   = linspace(f1, f2, nf);
0087       case 'log'
0088         f = logspace(log10(f1), log10(f2), nf);
0089     end
0090   end
0091 
0092 
0093   %%% Now compute the response
0094   if Q>=0.5
0095     re = 1 - (f.^2./f0^2);
0096     im = f ./ (f0*Q);
0097     r = 1./complex(re, im);
0098   else
0099     re = 1;
0100     im = f./f0;
0101     r = 1./complex(re, im);
0102   end
0103 end
0104 
0105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0106 %                               Local Functions                               %
0107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0108 
0109 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0110 %
0111 % FUNCTION:    getInfo
0112 %
0113 % DESCRIPTION: Get Info Object
0114 %
0115 % HISTORY:     11-07-07 M Hewitson
0116 %                Creation.
0117 %
0118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0119 
0120 function ii = getInfo(varargin)
0121   if nargin == 1 && strcmpi(varargin{1}, 'None')
0122     sets = {};
0123     pl   = [];
0124   else
0125     sets = {'Default'};
0126     pl   = getDefaultPlist;
0127   end
0128   % Build info object
0129   ii = minfo(mfilename, 'pz', '', utils.const.categories.sigproc, '$Id: resp.m,v 1.5 2008/09/04 15:29:31 ingo Exp $', sets, pl);
0130 end
0131 
0132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0133 %
0134 % FUNCTION:    getDefaultPlist
0135 %
0136 % DESCRIPTION: Get Default Plist
0137 %
0138 % HISTORY:     11-07-07 M Hewitson
0139 %                Creation.
0140 %
0141 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0142 
0143 function plo = getDefaultPlist()
0144   plo = plist();
0145 end
0146

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003