rationalfit - Approximate data using rational function
Syntax
h=rationalfit(freq,data)
h=rationalfit(freq,data,tol,weight,delayfactor,tendstozero,npoles,iterationlimit,showbar)
Description
h = rationalfit(freq,data) fits
a rational function model of the form

to the complex vector of passive values in data over
the frequency values in the positive vector freq.
The function returns a handle to the rational function model object, h,
with properties A, C, D,
and Delay.
h = rationalfit(freq,data,tol,weight,delayfactor,tendstozero,npoles,iterationlimit,showbar) fits
a rational function

to the data using optional arguments
that control the data fitting.
To see how well the model fits the original data, use the freqresp function
to compute the frequency response of the model. Then, plot the original
data and the frequency response of the rational function model. For
more information, see the freqresp reference
page or the examples in the next section.
Input Arguments
freq |
freq is a vector of M frequencies
over which the function fits a rational model.
|
data |
data is a N-by-N-by-M array
of data values.
|
tol |
tol is a scalar that specifies the relative
error-fitting tolerance in decibels. The error-fitting equation is
 where ε is the specified value of tol. F0 is the
value of the original data (data) at the specified
frequency fk (freq). F is the value of the rational
function at s = j2πf.
rationalfit computes the relative
error as a vector containing the dependent values of the fit data.
If the model does not fit the original data within the specified tolerance,
a warning message appears.
Default: -40 |
weight |
weight is a vector that specifies the weighting
of the fit at each frequency. Each entry in weight corresponds
to a frequency in freq. Increasing the weight at
a particular frequency improves the model fitting at that frequency.
Specifying a weight of 0 at a particular frequency
causes rationalfit to ignore the corresponding
data point. The length of weight must be equal
to the length of freq.
Default: ones(length(freq)) |
delayfactor |
delayfactor is a scaling factor between 0
and 1 that controls the amount of delay to fit the data. The Delay parameter, τ,
of the rational function object is equal to delayfactor times
the ratio of the phase difference of the data across the specified
frequencies to the difference between the maximum and minimum frequencies.
A value of 0 prevents loss of fitting accuracy
due to overestimation of the delay. However, increasing delayfactor might
allow rationalfit to fit the data accurately
with a lower-order model (with fewer poles).
Default: 0 |
tendstozero |
tendstozero is a logical value that determines
the behavior of the rational function as the frequency approaches
infinity. When this argument is true, the resulting
rational function variable D is zero. A value of 0 indicates
that D is nonzero. A rational function that tends
to zero is appropriate for almost every set of data. However, if rationalfit has
trouble fitting the data to a rational function, try changing the
value of tendstozero.
Default: true |
npoles |
npoles is an even integer or a two-element
vector [M,N] of even integers.
If npoles is an integer, it specifies
the exact number of poles, k, that rationalfit uses
to fit the rational function to the data. If npoles is a vector, it specifies
a range of values of the number of poles, k, to
fit the data.
To help rationalfit produce an accurate
fit, choose a maximum value of npoles greater than
or equal to twice the number of observable peaks on a plot of the
data in the frequency domain.
After completing a rational fit, the function removes coefficient
sets whose residues (Ck)
are zero. Thus, when you specify a range for npoles,
the number of poles of the fit may be less than npoles(1).
The default value of npoles depends on numel(freq) and
an offset value. The value of tendstozero determines
the offset. If tendstozero is true,
then offset is 0. If tendstozero is false,
then offset is 1.
Default: [0,min(48,numel(freq)-offset)] |
iterationlimit |
Control the number of iterations that rationalfit performs
for each value of npoles by specifying an integer
value for iterationlimit.
Default: 12 |
showbar |
Set this parameter to true to show the graphical
wait bar while rationalfit computes a rational
function fit. Set this parameter to false to hide
the wait bar.
Default: false |
Examples
Fit a rational function model to passive data, plot, and compare
results:
% Read RF data
orig_data = read(rfdata.data,'passive.s2p');
freq = orig_data.Freq;
data = orig_data.S_Parameters(1,1,:);
% Fit a rational function
fit_data = rationalfit(freq,data);
% Compute the frequency response of the fit
[resp,freq] = freqresp(fit_data,freq);
% Plot S11 magnitude (blue) and fit (red)
figure;
title('Rational fitting of S11 magnitude')
plot(orig_data,'S11','dB');
hold on;
plot(freq/1e9,db(resp),'r');
% Plot S11 angle (blue) and fit (red)
figure;
title('Rational fitting of S11 angle')
plot(orig_data,'S11','Angle (radians)');
hold on;
plot(freq/1e9,unwrap(angle(resp)),'r');
References
B. Gustavsen and A. Semlyen, "Rational approximation
of frequency domain responses by vector fitting," IEEE Trans.
Power Delivery, Vol. 14,
No. 3, pp. 1052–1061, July 1999.
R. Zeng and J. Sinsky, "Modified Rational Function Modeling
Technique for High Speed Circuits," IEEE MTT-S Int. Microwave
Symp. Dig., San Francisco, CA, June 11–16, 2006.
See Also
freqresp | rfmodel.rational | s2tf | timeresp | writeva
Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
Get the Interactive Kit