Main Content


Write RF data from circuit or data object to file



status = write(data,filename,dataformat,funit,printformat,freqformat) writes information from data to the specified file. The write function returns True if the operation is successful and returns False otherwise.


The method only writes property values from data that the specified output file supports. For example, Touchstone files, which have the .snp, .ynp, .znp, or .hnp extension, do not support noise figure or output third-order intercept point. Consequently, the write method does not write these property values to these such files.


collapse all

Read the data stored in the file default.s2p

orig_data = with properties:

            Freq: [191x1 double]
    S_Parameters: [2x2x191 double]
      GroupDelay: [191x1 double]
              NF: [191x1 double]
            OIP3: [191x1 double]
              Z0: 50.0000 + 0.0000i
              ZS: 50.0000 + 0.0000i
              ZL: 50.0000 + 0.0000i
        IntpType: 'Linear'
            Name: 'Data object'

Analyze the data stored in the specified file for a set of frequency values.

freq = [1:.1:2]*1e9;

Use the write function to store the results in a file called test.s2p.

ans = logical

Input Arguments

collapse all

Object that contains sufficient information to write the specified files, specified as an RF circuit or data object.

File name of a .snp, .ynp, .znp, .hnp, or .amp file extensions, where n is the number of ports, specified as a character vector, or string scalar.

Data format to be written, specified as a character vector or string scalar. It must be one of the case-insensitive values specified in the following table.




Data is given in (dB-magnitude, angle) pairs with angle in degrees.


Data is given in (magnitude, angle) pairs with angle in degrees.


Data is given in (real, imaginary) pairs (default).

Frequency units of the data, specified in 'GHz', 'MHz', 'KHz', or 'Hz'.


If you do not specify funit, its value is taken from the object data. All values are case-insensitive

Represents precision of the network and noise parameters, specified using formatting operators. For example, if you set the printformat to %22.10f, this means that the method writes the data using fixed-point notation with a precision of 10 digits. The minimum positive value that the write function can express by default is 1e-10. For greater precision, specify a different printformat. See the formatspec argument in the fprintf function for more information.

Represents precision of the frequency, specified using formatting operators. See fprintf for more information.


[1] EIA/IBIS Open Forum, “ Touchstone File Format Specification,” Rev. 1.1, 2002 (

Version History

Introduced before R2006a