Main Content

rationalfit

Approximate data using stable rational function object

Description

The rationalfit function uses vector fitting with complex frequencies to perform rational fitting on a complex frequency-dependent data. The rationalfit returns an rfmodel.rational object. The fit of the each element of the rationalfit function is given by this equation:

F(s)=(C(1)SA(1)+C(2)SA(2)+...+C(n)SA(n)+D)e(Sdelaydelayfactor)WhereA         Poles of the rationalfit functionC         Residues of the rationalfit functionD         Frequency response offsetDelay  Frequency response time delayS          Complex frequencies (j2πfreqdata)

Note

rational is recommend over rationalfit because it enables faster simulation and improved fitting of complex frequency-dependent data. (since R2023b)

fit = rationalfit creates a non-reflective one-port rationalfit object with default properties.

fit = rationalfit(freq,data) performs rational fitting for the given frequency vector freq and network parameter data data.

example

fit = rationalfit(s) performs rational fitting for the N-port S-parameters object s.

fit = rationalfit(filename) performs rational fitting of network data in the file specified in filename.

fit = rationalfit(___,tol) strives to satisfy the relative error tolerance tol when performing rational fit.

fit = rationalfit(s,i,j) performs the rational fitting only on the (i,j)th element of the N-port sparameters object s.

example

fit = rationalfit(___,Name=Value) specifies options to control aspects of fit. For example, fit = rationalfit(s,PoleSharing='Column') shares the poles by S-parameter column terms for the fit. Specify name-value arguments after any of the input arguments from the previous syntaxes.

[fit,errdb] = rationalfit(___)also returns the error of the fit errdb.

Examples

collapse all

Fit a rational function object to S-parameter data, and compare the results by plotting the object against the data.

Read the S-parameter data into an RF data object.

orig_data = read(rfdata.data,'passive.s2p');
freq = orig_data.Freq;
data = orig_data.S_Parameters(1,1,:);

Fit a rational function to the data using rationalfit.

fit_data = rationalfit(freq,data)
fit_data = 
   rfmodel.rational with properties:

        A: [19x1 double]
        C: [19x1 double]
        D: 0
    Delay: 0
     Name: 'Rational Function'

Compute the frequency response of the rational function using freqresp.

[resp,freq] = freqresp(fit_data,freq);

Plot the magnitude of the original data against the rational function approximation. S11 data appears in blue, and the rational function appears in red. Scaling the frequency values by 1e9 converts them to units of GHz.

figure
title('Rational fitting of S11 magnitude')
plot(orig_data,'S11','dB')
hold on
plot(freq/1e9,20*log10(abs(resp)),'r');

Figure contains an axes object. The axes object with xlabel Freq [GHz], ylabel Magnitude (decibels) contains 2 objects of type line. This object represents S_{11}.

Plot the angle of the original data against the rational function approximation.

figure
title('Rational fitting of S11 angle')
plot(orig_data,'S11','Angle (radians)')
hold on
plot(freq/1e9,unwrap(angle(resp)),'r')

Figure contains an axes object. The axes object with xlabel Freq [GHz], ylabel Angle (radians) contains 2 objects of type line. This object represents S_{11}.

rationalfit(freq,data) also handles input 3D array of data (n x n x p), an input frequency array (p x 1), and returns a matrix (n x n) of rationalfit objects. Index into the matrix of rationalfit objects to access corresponding rationalfit information.

Use rationalfit on multiple datasets defined in a matrix.

orig_data = sparameters('defaultbandpass.s2p'); 
data = orig_data.Parameters; 
freq = orig_data.Frequencies;
fit_data = rationalfit(freq, data)
fit_data = 
  2x2 rfmodel.rational array with properties:

    A
    C
    D
    Delay
    Name

To access rationalfit data, use indexing on the rationalfit array. For example, to access the rational fit for the 1st element of the matrix, use:

S = fit_data(1, 1)
S = 
   rfmodel.rational with properties:

        A: [12x1 double]
        C: [12x1 double]
        D: 0
    Delay: 0
     Name: 'Rational Function'

Create a sparameter object from the file passive.s2p.

S = sparameters('passive.s2p');

Use the rationalfit object to fit a sparameter object and calculate the relative error tolerance of the fit.

[fit,errdB] = rationalfit(S,1,1,'TendsToZero',false)
fit = 
   rfmodel.rational with properties:

        A: [5x1 double]
        C: [5x1 double]
        D: -0.4843
    Delay: 0
     Name: 'Rational Function'

errdB = 
-40.6263

Input Arguments

collapse all

Nonnegative frequencies, specified as a vector of nonnegative frequencies in Hz.

Data Types: double

Network parameter data, specified as a vector, a 2-D array or a 3-D array. The length of the data values must equal the length of the frequency values freq.

Error tolerance ε, specified as a scalar in units of dB. The error-fitting equation is

10ε/20k=0n|WkF0{fk}F(s)|2k=0n|WkF0{fk}|2

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.

  • W is the weighting of the data.

Note

  • Do not specify the tol input argument and Tolerance name-value argument when specifying number of poles of the fit using the NPoles property.

  • The rationalfit function computes the relative error as a vector containing the dependent values of the fit data. If the object does not fit the original data within the specified tolerance, a warning message appears.

S-parameters, specified as sparameters object.

Network data file name, specified as a character vector. The data file must have .snp file extension (a Touchstone file).

Row index of data to plot, specified as a positive integer.

Column index of data to plot, specified as a positive integer.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'DelayFactor',0.2

Scaling factor that controls the amount of delay to fit to the data, specified as a scalar between 0 and 1 inclusive. The Delay parameter of the rationalfit function is equal to the specified value of 'DelayFactor' times an estimate of the group delay of the data. If the original data has delay, increasing this value might allow rationalfit to fit the data with a lower-order object.

Maximum number of rationalfit iterations, specified as a two-element vector of positive integers. Provide a two-element vector to specify minimum and maximum [M1 M2] of rational fit iterations. Increasing the limit extends the time that the algorithm takes to produce a fit, but it might produce more accurate results.

Number of poles, specified as an nonegative integer or vector of two nonnegative integers.

For an accurate rational fit, choose a maximum value of Npoles greater than or equal to twice the number of 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).

Note

Do not specify tol as one of the inputs or Tolerance as one of the name-value arguments when specifying number of poles of the fit using the NPoles name-value argument.

Asymptotic behavior of the rational function as frequency approaches infinity, specified as a logical value. When this argument is true, the resulting rational function variable D is zero, and the function tends to zero. A value of false allows a nonzero value for D.

Error tolerance ε, specified as the comma-separated pair consisting of 'Tolerance' and a scalar in units of dB. The error-fitting equation is

10ε/20k=0n|WkF0{fk}F(s)|2k=0n|WkF0{fk}|2

where

  • ε is the specified tolerance.

  • 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.

  • W is the weighting of the data.

Note

  • Do not specify tol as one of the inputs or Tolerance as one of the name-value arguments when specifying number of poles of the fit using the NPoles name-value argument.

  • The rationalfit function computes the relative error as a vector containing the dependent values of the fit data. If the object does not fit the original data within the specified tolerance, a warning message appears.

Since R2024a

Type of pole sharing to share the poles of the S-parameters, specified as one of the following:

  • All — Share all the poles of the S-parameters.

  • Column — Share the poles by S-parameter column terms.

  • Individual — Share the poles individually by S-parameter terms.

Data Types: char | string

Logical value that toggles display of the graphical wait bar during fitting, specified as either true or false. The true setting shows the graphical wait bar, and the false setting hides it. If you expect rationalfit to take a long time, and you want to monitor its progress, set 'WaitBar' to true.

Weighting of the data at each frequency, specified as a vector of positive numbers or an array same as that of the data. Each entry in weight corresponds to a frequency in freq, so the length of weight must be equal to the length of freq. Increasing the weight at a particular frequency improves the object fitting at that frequency.

Note

Specifying a weight of 0 at a particular frequency causes rationalfit to ignore the corresponding data point.

Output Arguments

collapse all

One or more rational function objects, returned as an N-by-N rfmodel.rational object. The number of dimensions in data determines the dimensionality of h.

Relative error achieved, returned as a double, in dB.

Tips

To see how well the object fits the original data, use the freqresp function to compute the frequency response of the object. Then, plot the original data and the frequency response of the rational function object. For more information, see the freqresp reference page or the above examples.

References

[1] Gustavsen.B 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.

[2] Zeng.R 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.

Version History

Introduced in R2006b

expand all