Documentation Center

  • Trial Software
  • Product Updates

plotyy

Plot specified object parameters with y-axes on both left and right sides

Syntax

[ax,hlines1,hlines2] = plotyy(h,parameter)
[ax,hlines1,hlines2] = plotyy(h,parameter1,...,parametern)
[ax,hlines1,hlines2] = plotyy(h,parameter,format1,format2)
[ax,hlines1,hlines2] = plotyy(h, parameter1, ..., parametern, format1, format2)
[ax,hlines1,hlines2] = plotyy(h,parameter1_1,...,parameter1_n1, format1,parameter2_1,...,parameter2_n2,format2)
[ax,hlines1,hlines2] = plotyy(h,parameter1_1,...,parameter1_n1, format1,parameter2_1,...,parameter2_n2,format2,xparameter, xformat,'condition1',value1,...,'conditionm',valuem, 'freq',freq,'pin',pin)

Description

[ax,hlines1,hlines2] = plotyy(h,parameter) plots the specified parameter using the predefined primary and secondary formats for the left and right y-axes, respectively. The formats define how RF Toolbox™ software displays the data on the plot. h is the handle of a circuit (rfckt) or an rfdata.data object.

  • See Determining Formats for a table that shows the predefined primary and secondary formats for the parameters for all circuit and data objects.

  • Type listparam(h) to get a list of valid parameters for a circuit object, h. Type listformat(h,parameter) to see the legitimate formats for a specified parameter. The first listed format is the default for the specified parameter.

The plotyy method returns the handles to the two axes created in ax and the handles to two lineseries objects in hlines1 and hlines2.

  • ax(1) is the left axes.

  • ax(2) is the right axes.

  • hlines1 is the lineseries object for the left y-axis.

  • hlines2 is the lineseries object for the right y-axis.

    Note:   For all circuit objects except those that contain data from a data file, you must perform a frequency domain analysis with the analyze method before calling plotyy.

Use the Property Editor (propertyeditor) or the MATLAB® set function to change lineseries properties. The reference pages for MATLAB functions such as figure, axes, and text also list available properties and provide links to more complete property descriptions.

    Note:   Use the MATLAB plotyy function to plot parameters on two y-axes that are specified as vector data and are not part of a circuit (rfckt) object or data (rfdata) object.

[ax,hlines1,hlines2] = plotyy(h,parameter1,...,parametern) plots the parameters parameter1,..., parametern. plotyy determines the formats for the left and right y-axes based on the predefined primary and secondary formats for the specified parameters, as described in Determining Formats.

[ax,hlines1,hlines2] = plotyy(h,parameter,format1,format2) plots the specified parameter using format1 for the left y-axis and format2 for the right y-axis.

[ax,hlines1,hlines2] = plotyy(h, parameter1, ..., parametern, format1, format2) plots the parametersparameter1,..., parametern on an X-Y plane using format1 for the left y-axis and format2 for the right y-axis.

[ax,hlines1,hlines2] = plotyy(h,parameter1_1,...,parameter1_n1, format1,parameter2_1,...,parameter2_n2,format2) plots the following data:

  • Parameters parameter1_1,..., parameter1_n1 using format1 for the left y-axis.

  • Parameters parameter2_1,..., parameter2_n2 using format2 for the right y-axis.

[ax,hlines1,hlines2] = plotyy(h,parameter1_1,...,parameter1_n1, format1,parameter2_1,...,parameter2_n2,format2,xparameter, xformat,'condition1',value1,...,'conditionm',valuem, 'freq',freq,'pin',pin) plots the specified parameters at the specified operating conditions for the object h.

xparameter is the independent variable to use in plotting the specified parameters. Several xparameter values are available for all objects. When you import rfckt.amplifier, rfckt.mixer, or rfdata.data object specifications from a .p2d or .s2d file, you can also specify any operating conditions from the file that have numeric values, such as bias.

The following table shows the most commonly available parameters and the corresponding xparameter values. The default settings listed in the table are used if xparameter is not specified.

Parameter Namexparameter values
Pout, Phase, LS11, LS12, LS21, LS22Pin (default), Freq
S11, S12, S21, S22, NF, IIP3, OIP3, GroupDelay, VSWRIn, VSWROut, GammaIn, GammaOut, FMIN, GammaOPT, RN, TF1, TF2, Gt, Ga, Gp, Gmag, Gmsg, GammaMS, GammaML, K, Delta, Mu, MuPrimeFreq
AM/AM, AM/PMAM

xformat is the format to use for the specified xparameter. No xformat specification is needed when xparameter is an operating condition.

The following table shows the xformat values that are available for the xparameter values listed in the preceding table, along with the default settings that are used if xformat is not specified.

xparameter valuesxformat values
PindBm (default), mW, W, dBW
Freq

THz, GHz, MHz, KHz, Hz

By default, xformat is chosen to provide the best scaling for the given xparameter values.

AMMagnitude (decibels) (default), Magnitude (linear)

condition1,value1,..., conditionm,valuem are the optional condition/value pairs at which to plot the specified parameters. These pairs are usually operating conditions from a .p2d or .s2d file. For some parameters, you can specify a set of frequency or input power values at which to plot the specified parameter.

For example:

  • When plotting large-signal S-parameters as a function of input power, you can specify frequency points of interest using condition/value pairs.

  • When plotting large-signal S-parameters as a function of frequency, you can specify input power levels of interest using condition/value pairs.

  • When plotting parameters as a function of an operating condition, you can specify both frequency and input power values using condition/value pairs.

freq is the optional frequency value, in hertz, at which to plot the specified parameters.

pin is the optional input power value, in dBm, at which to plot the specified parameters.

If h has multiple operating conditions, such as from a .p2d or .s2d file, the plotyy method operates as follows:

  • If you do not specify any operating conditions as arguments to the plotyy method, then the method plots the parameter values based on the currently selected operating condition.

  • If you specify one or more operating conditions, the plotyy method plots the parameter values based on those operating conditions.

  • When you use an operating condition for the xparameter input argument, the method plots the parameters for all operating condition values.

Determining Formats

When you call plotyy without specifying the plot formats for the left and right y-axes, plotyy determines the formats from the predefined primary and secondary formats for the one or more specified parameters.

This section contains the following topics:

Primary and Secondary Formats

The following table shows the primary and secondary formats for the parameters for all circuit and data objects. Use the listparam method to list the valid parameters for a particular object. Use the listformat method to list valid formats.

ParameterPrimary FormatSecondary Format

S11, S12, S21, S22

Magnitude (decibels)Angle (Degrees)

LS11, LS12, LS21, LS22

Magnitude (decibels)Angle (Degrees)
NFMagnitude (decibels) 
OIP3dBmW
PoutdBmW
PhaseAngle (Degrees) 
AM/AMMagnitude (decibels) 
AM/PMAngle (Degrees) 

GammaIn, GammaOut

Magnitude (decibels)Angle (Degrees)
Gt, Ga, Gp, Gmag, GmsgMagnitude (decibels) 
DeltaMagnitude (decibels)Angle (Degrees)

TF1, TF2

Magnitude (decibels)Angle (Degrees)

GammaMS, GammaML

Magnitude (decibels)Angle (Degrees)

VSWRIn, VSWROut

Magnitude (decibels) 
GroupDelayns 
FminMagnitude (decibels) 

GammaOPT

Magnitude (decibels)Angle (Degrees)

K, Mu, MuPrime

None 

RN

None 
PhaseNoisedBc/Hz 
NTempK 

NFactor

None 

Determining Formats for One Parameter

When you specify only one parameter for plotting, plotyy creates the plot as follows:

  • The predefined primary format is the format for the left y-axis.

  • The predefined secondary format is the format for the right y-axis.

If the specified parameter does not have the predefined secondary format, plotyy behaves the same way as plot, and does not add a second y-axis to the plot.

Determining Formats for Multiple Parameters

To plot multiple parameters on two y-axes, plotyy tries to find two formats from the predefined primary and secondary formats for the specified parameters. To be used in the plot, the formats must meet the following criteria:

  • Each format must be a valid format for at least one parameter.

  • Each parameter must be plotted at least on one y-axis.

If plotyy cannot meet this criteria it issues an error message.

The function uses the following algorithm to determine the two parameters:

  1. Look up the primary and secondary formats for the specified parameters.

  2. If one or more pairs of primary-secondary formats meets the preceding criteria for all parameters:

    • Select the pair that applies to the most parameters.

    • Use these formats to create the plot.

    Otherwise, proceed to the next step.

  3. If no pairs of primary-secondary formats meet the criteria for all parameters, try to find one or more pairs of primary-primary formats that meets the criteria. If one or more pairs of primary-primary formats meets the preceding criteria for all parameters:

    • Select the pair that applies to the most parameters.

    • Use these formats to create the plot.

    Otherwise, proceed to the next step.

  4. If the preceding steps fail to produce a plot, try to find one format from the predefined primary formats. If a primary format is valid for all parameters, use this format to create the plot with the MATLAB plot function.

    If this is not successful, issue an error message.

The following example shows how plotyy applies this criteria to create plots.

Example — Determining Formats for Multiple Parameters

At the MATLAB prompt:

  1. Type this command to create an rfckt object called amp:

    amp = rfckt.amplifier;
    
  2. Type this command to plot the S11 and S21 parameters of amp on two y-axes: .

    plotyy(amp, 'S11', 'S21')
    

    The primary and secondary formats for both S11 and S21 are Magnitude (decibels) and Angle (Degrees), respectively, so plotyy uses this primary-secondary format pair to create the plot

  3. Type this command to plot the S11 and NF parameters of amp on two y-axes:

    plotyy(amp, 'S11', 'NF')
    

    The primary and secondary formats for S11 are Magnitude (decibels) and Angle (Degrees), respectively.

    • Magnitude (decibels) is a valid format for both S11 and NF

    • Angle (Degrees) is a valid format for S11.

    These formats both meet the preceding criteria, so the function uses this primary-secondary format pair to create the plot.

  4. Type this command to plot the NF, S21 and GroupDelay parameters of amp on two y-axes:

    plotyy(amp, 'NF', 'S21', 'GroupDelay')
    

    The primary and secondary formats for S21 are Magnitude (decibels) and Angle (Degrees), respectively. Both NF and GroupDelay have only a primary format.

    • Magnitude (decibels) is the primary format for NF.

    • ns is the primary format for GroupDelay.

    There is no primary-secondary format pair that meets the preceding criteria, so plotyy tries to find a pair of primary formats that meet the criteria. plotyy creates the plot using:

    • Magnitude (decibels) for the left y-axis.

      This format is valid for both NF and S21.

    • ns for the right y-axis.

      This format is valid for GroupDelay .

    These formats meet the criteria.

  5. Type this command to plot the NFactor and K parameters of amp on two y-axes:

    plotyy(amp, 'NFactor', 'K')
    

    Both NFactor and K have only a primary format,None, so plotyy calls the plot command to create a plot with a single y-axis whose format is None.

  6. Type this command to plot the NTemp, S21 and NFactor parameters of amp on two y-axes:

    plotyy(amp, 'NTemp', 'S21', 'NFactor')
    
    ??? Error using ==> rfdata.data.plotyyprocess at 97
    No format specified for input parameters and cannot reconcile
    default formats. Try reducing the number of parameters to plotyy
    and explicitly specifying formats.
    

    The primary and secondary formats for S21 are Magnitude (decibels) and Angle (Degrees), respectively. Both NTemp and NFactor have only a primary format.

    • Kelvin is the primary format for NTemp.

    • None is the primary format for NFactor.

    These parameters have no formats in common, so no formats meet the criteria and plotyy issues an error message.

See Also

| | | | | | | | | | | | | |

Was this topic helpful?