1 %% Copyright (C) 2006 Peter V. Lanspeary <pvl@mecheng.adelaide.edu.au>
3 %% This program is free software; you can redistribute it and/or modify it under
4 %% the terms of the GNU General Public License as published by the Free Software
5 %% Foundation; either version 3 of the License, or (at your option) any later
8 %% This program is distributed in the hope that it will be useful, but WITHOUT
9 %% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 %% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 %% You should have received a copy of the GNU General Public License along with
14 %% this program; if not, see <http://www.gnu.org/licenses/>.
17 %% [Pxx,freq] = tfe(x,y,Nfft,Fs,window,overlap,range,plot_type,detrend)
19 %% Estimate transfer function of system with input "x" and output "y".
20 %% Use the Welch (1967) periodogram/FFT method.
21 %% Compatible with Matlab R11 tfe and earlier.
22 %% See "help pwelch" for description of arguments, hints and references
23 %% --- especially hint (7) for Matlab R11 defaults.
25 function [varargout] = tfe(varargin)
27 %% Check fixed argument
29 error( 'tfe: Need at least 2 args. Use help tfe.' );
31 nvarargin = length(varargin);
32 %% remove any pwelch RESULT args and add 'trans'
35 if ( ~isempty(arg) && ischar(arg) && ( strcmp(arg,'power') || ...
36 strcmp(arg,'cross') || strcmp(arg,'trans') || ...
37 strcmp(arg,'coher') || strcmp(arg,'ypower') ))
41 varargin{nvarargin+1} = 'trans';
43 saved_compatib = pwelch('R11-');
47 Pxx = pwelch(varargin{:});
50 [Pxx,f] = pwelch(varargin{:});
54 pwelch(saved_compatib);