# sparameters

Calculate S-parameters for RF data, network, circuit, and matching network objects

## Syntax

``sobj = sparameters(filename)``
``sobj = sparameters(data,freq)``
``sobj = sparameters(data,freq,Z0)``
``sobj = sparameters(rfobj,freq)``
``sobj = sparameters(rfobj,freq,Z0)``
``sobj = sparameters(netparamobj)``
``sobj = sparameters(netparamobj,Z0)``
``sobj = sparameters(rfdataorckt)``
``sobj = sparameters(mnobj)``
``sobj = sparameters(mnobj,freq)``
``sobj = sparameters(mnobj,freq,Z0)``
``sobj = sparameters(___,circuitindices)``

## Description

example

````sobj = sparameters(filename)` creates an S-parameter object `sobj` by importing data from the Touchstone file specified by `filename`.```
````sobj = sparameters(data,freq)` creates an S-parameter object from the S-parameter data, `data`, and frequencies, `freq`.```
````sobj = sparameters(data,freq,Z0)` creates an S-parameter object from the S-parameter data, `data`, and frequencies, `freq`, with a given reference impedance `Z0`. ```
````sobj = sparameters(rfobj,freq)` calculates the S-parameters of a RF object such as a filter object, circuit object, transmission line object, series RLC object, shunt RLC object, attenuator object or RF antenna object with the default reference impedance. ```

example

````sobj = sparameters(rfobj,freq,Z0)` calculates the S-parameters of a RF object such as a filter object, circuit object or transmission line object with a given reference impedance `Z0`. ```
````sobj = sparameters(netparamobj)` converts the network parameter object, `netparamobj`, to S-parameter object with the default reference impedance. ```

example

````sobj = sparameters(netparamobj,Z0)` converts the network parameter object, `netparamobj`, to S-parameter object with a given reference impedance, `Z0`. ```

example

````sobj = sparameters(rfdataorckt)` extracts network data from `rfdataobj` or `rfcktobj` and converts it into S-parameter object.```
````sobj = sparameters(mnobj)` returns the S-parameters of the best created matching network, evaluated at a frequency list constructed from source and load impedance.```
````sobj = sparameters(mnobj,freq)` returns the S-parameters of the best created matching network at each specified frequency.```
````sobj = sparameters(mnobj,freq,Z0)` returns the S-parameters of the best created matching network at each specified frequency and characteristic impedance, `Z0`.```

example

````sobj = sparameters(___,circuitindices)` returns an array of S-parameter objects, one object for each circuit indicated in `circuitindices`. Use this option with any of the input argument combinations in the previous syntaxes.```

## Examples

collapse all

Extract S-parameters from file `default.s2p` and plot it.

```S = sparameters('default.s2p'); disp(S)```
``` sparameters: S-parameters object NumPorts: 2 Frequencies: [191x1 double] Parameters: [2x2x191 double] Impedance: 50 rfparam(obj,i,j) returns S-parameter Sij ```

Plot the extracted S-parameters data.

`rfplot(S)`

Create a resistor element R50 and add it to a circuit object `example2` . Calculate the S-parameters of `example2` .

```hR1 = resistor(50,'R50'); hckt1 = circuit('example2'); add(hckt1,[1 2],hR1) setports (hckt1, [1 0],[2 0]) freq = linspace (1e3,2e3,100); S = sparameters(hckt1,freq,100); disp(S)```
``` sparameters: S-parameters object NumPorts: 2 Frequencies: [100x1 double] Parameters: [2x2x100 double] Impedance: 100 rfparam(obj,i,j) returns S-parameter Sij ```

Extract Y-parameters from file default.s2p. Convert the resulting Y-parameters to S-parameters.

```Y1 = yparameters('default.s2p'); S1 = sparameters(Y1,100); disp(Y1)```
``` yparameters: Y-parameters object NumPorts: 2 Frequencies: [191x1 double] Parameters: [2x2x191 double] rfparam(obj,i,j) returns Y-parameter Yij ```
`disp(S1)`
``` sparameters: S-parameters object NumPorts: 2 Frequencies: [191x1 double] Parameters: [2x2x191 double] Impedance: 100 rfparam(obj,i,j) returns S-parameter Sij ```
```file = 'default.s2p'; h = read(rfdata.data, file); S = sparameters(h)```
```S = sparameters: S-parameters object NumPorts: 2 Frequencies: [191x1 double] Parameters: [2x2x191 double] Impedance: 50 rfparam(obj,i,j) returns S-parameter Sij ```

This example shows how to calculate the S-Parameters for a newly created matching network for the auto-generated circuit #2 with a reference impedance of 100 Ohm.

```n = matchingnetwork('LoadImpedance',100,'Components',3); freq = linspace(n.CenterFrequency-n.Bandwidth/2,n.CenterFrequency+n.Bandwidth/2); RefZ0 = 100; ckt_no = 2; s = sparameters(n,freq,RefZ0,ckt_no)```
```s = sparameters: S-parameters object NumPorts: 2 Frequencies: [100x1 double] Parameters: [2x2x100 double] Impedance: 100 rfparam(obj,i,j) returns S-parameter Sij ```

Create an RLCG transmission line using these specifications:

• Resistor : 100 ohms

• Capacitor : 1 pF

`rlcglinetxline = txlineRLCGLine(R=100,C=1e-12)`
```rlcglinetxline = txlineRLCGLine: RLCGLine element Name: 'RLCGLine' Frequency: 1.0000e+09 R: 100 L: 0 C: 1.0000e-12 G: 0 IntpType: 'Linear' LineLength: 0.0100 Termination: 'NotApplicable' StubMode: 'NotAStub' NumPorts: 2 Terminals: {'p1+' 'p2+' 'p1-' 'p2-'} ```

Calculate the S-parameters of the transmission line at 1 GHz.

`sparam = sparameters(rlcglinetxline,1e9);`

Define a data set and a vector of frequencies.

```data = reshape(complex(1:12,13:24),2,2,[]); freq = (1:3)*10^9;```

Define the reference impedance of each port of the data.

`Z0 = [50 100];`

Build the S-parameters object of the data at the given frequencies `freq` with the vector `Z0` of reference impedances. This will allow you to specify different reference impedance for each port.

`S = sparameters(data,freq,Z0)`
```S = sparameters: S-parameters object NumPorts: 2 Frequencies: [3x1 double] Parameters: [2x2x3 double] Impedance: [50 100] rfparam(obj,i,j) returns S-parameter Sij ```

## Input Arguments

collapse all

S-parameter data, specified as an array of complex numbers, of size N-by-N-by-K.

RF object, specified as one of the following:

 Circuit object `circuit` RF Filter object `rffilter` and `lcladder`. Transmission line objects Series and Shunt RLC objects `seriesRLC`, and `shuntRLC` Attenuator object `attenuator` RF antenna object `rfantenna` Phase shift object `phaseshift` IMT mixer object `mixerIMT` RF divider object (since R2023a) `rfdivider` Mutual inductor object (since R2023a) `mutualInductor`

Network parameter object. The network parameter objects are of the type: `sparameters`, `yparameters`, `zparameters`, `gparameters`, `hparameters`, `abcdparameters`, and `tparameters`.

Example: `S1 = sparameters(Y1,100)` . `Y1` is a parameter object. This example converts Y-parameters to S-parameters at `100` ohms.

Touchstone data file, specified as a character vector, that contains network parameter data. `filename` can be the name of a file on the MATLAB® path or the full path to a file.

Example: ```sobj = sparameters('defaultbandpass.s2p');```

S-parameter frequencies, specified as a vector of positive real numbers, sorted from smallest to largest.

Reference impedance in ohms, specified as one of the following:

• Positive real scalar when you want to specify the same the reference impedance for all ports in the network.

• Positive real vector of length N when you want to specify a different reference impedance for each port in the N-port network. (since R2023a)

• Positive real vector of length K when you want to specify a different reference impedance for each in the K frequencies in the data. (since R2023a)

If the reference impedance is a vector and the number of ports N equals the number of data frequencies K, N == K, then the `sparameters` object will assign each element of the vector to each port of the network. To specify reference impedances for each frequency in this case, specify `Z0` as a 3-D vector of length 1-by-1-by-K .

You cannot specify the `Z0` argument if you are importing the S-parameters data from a file. The `Z0` argument is optional and the function stores the impedance in the `Impedance` property of the `sparameters` object.

RF data or circuit object. Specify `rfdataobj` as either `rfdata.data`, or `rfdata.network` object or specify `rfcktobj` as any analyzed `rfckt` type object, such as `rfckt.amplifier`, `rkckt.cascade` object.

Matching network, specified as a `matchingnetwork` object.

Data Types: `char` | `string`

Index of the matching network circuit, specified as a scalar.

Data Types: `double`

## Output Arguments

collapse all

S-parameter data, returned as an object. `disp(sobj)` returns the properties of the object:

• `NumPorts` — Number of ports, specified as an integer. The function calculates this value automatically when you create the object.

• `Frequencies` — S-parameter frequencies, specified as a K-by-1 vector of positive real numbers sorted from smallest to largest. The function sets this property from the `filename` or `freq` input arguments.

• `Parameters` — S-parameter data, specified as an N-by-N-by-K array of complex numbers. The function sets this property from the `filename` or `data` input arguments.

• `Impedance` — Reference impedance in ohms, specified as a positive real scalar. The function sets this property from the `filename` or `Z0` input arguments. If no reference impedance is provided, the function uses a default value of `50`.

## Version History

Introduced in R2012a

expand all