main content

using rational object to fit s-凯发k8网页登录

this example shows how to use the rational object to create a rational fit to s-parameter data, and the various properties and methods that are included in the rational object.

create rational object

read in the sparameters, and create the rational object from them. the rational function automatically fits all entries of the s-parameter matrices.

s = sparameters('sawfilter.s2p')
s = 
  sparameters: s-parameters object
       numports: 2
    frequencies: [334x1 double]
     parameters: [2x2x334 double]
      impedance: 50
  rfparam(obj,i,j) returns s-parameter sij
r = rational(s)
r = 
  rational with properties:
      numports: 2
      numpoles: 24
         poles: [24x1 double]
      residues: [2x2x24 double]
    directterm: [2x2 double]
         errdb: -40.9658

with the default settings on this example, the rational function achieves an accuracy of about -26 db, using 30 poles. by construction, the rational object is causal, with a non-zero direct term.

compare fit with original data

generate the frequency response from the rational object, and compare one of the entries with the original data.

resp = freqresp(r, s.frequencies);
plot(s.frequencies, real(rfparam(s, 1, 1)), ...
    s.frequencies, real(squeeze(resp(1,1,:))))

figure contains an axes object. the axes object contains 2 objects of type line.

limit number of poles

redo the fit, limiting the number of poles to a maximum of 5. the rational object may use fewer poles than specified. notice that the quality of the fit is degraded as opposed to the original 30-pole fit.

r5 = rational(s, 'maxpoles', 5)
r5 = 
  rational with properties:
      numports: 2
      numpoles: 4
         poles: [4x1 double]
      residues: [2x2x4 double]
    directterm: [2x2 double]
         errdb: -1.7376
resp5 = freqresp(r5, s.frequencies);
plot(s.frequencies, real(rfparam(s, 1, 1)), ...
    s.frequencies, real(squeeze(resp5(1,1,:))))

figure contains an axes object. the axes object contains 2 objects of type line.

tighten target accuracy

redo the fit, asking for a tighter tolerance (-60 db), notice that the fit is significantly improved, particularly in the stopbands of the saw filter.

rgood = rational(s, -60)
rgood = 
  rational with properties:
      numports: 2
      numpoles: 188
         poles: [188x1 double]
      residues: [2x2x188 double]
    directterm: [2x2 double]
         errdb: -53.6397
respgood = freqresp(rgood, s.frequencies);
plot(s.frequencies, real(rfparam(s, 1, 1)), ...
    s.frequencies, real(squeeze(respgood(1,1,:))))

figure contains an axes object. the axes object contains 2 objects of type line.

related topics

网站地图