##### Page tree
Go to start of banner

# Equations

Equations perform complex mathematical operations on data. You can display equations results on data display plots, enabling you to analyze information in various ways.

This section describes how to write equations and how to display the results. It includes examples of how to use some of the mathematical expressions that are in Advanced Design System. A reference of the functions that are available can be found online, it can be accessed from the Equations dialog box.

Equations can be simple or very complex. An equation can include:

• Mathematical expressions and operations
• Functions
• Other data display equations
• Dataset variables
• Dataset information
• Marker labels

The rules for writing expressions are minimal:

• Equations are case-sensitive
• All functions must be completed using the given syntax
• Parentheses are used to define order of operation
• Reserved names cannot be used as equation variables. For example, you cannot use mag as the variable `mag=[1::3]`. Instead, it would need to be used as `mymag=[1::3]` or something similar.

## Inserting Equations

To insert an equation on the data display:

1. Click the Equation button from the palette or choose Insert > Equation.
2. Position the pointer on the display area and click the mouse. The Enter Equation dialog box appears.

3. Enter an equation with the equation variable name on the left side and the expression on the right. A sample equation is shown below.

The expression can include any of the items in the previous list. Note that the Dataset name is not required if the Dataset variable is included in the default dataset.
Click the Functions Help button for an alphabetical list of links to the available measurement functions. Click the Index tab in the left-hand frame of the Measurement Expressions documentation for an optional method of scrolling through the list of functions.

Note

Only the functions described in the " Measurement Expressions" documentation should be used to write Data Display equations.

4. To add a dataset variable to the equation, position the cursor in the equation where you want to insert the variable.
5. Select the dataset name from the list box.
6. A list of variables in the dataset is presented. Select a variable from this list and click Insert.
7. To modify the display properties of an expression, click Equation Properties. For more information, refer to Editing Text.
8. Activate the Show Hierarchy checkbox to display the dataset variables in a tree format. For more information, refer to Using the Dataset Browser.
9. Click the Manage Datasets button to locate a dataset that is not available in the current project. For more information, refer to Dataset Aliasing.
10. Click the Variable Info button to access the Browse Data dialog box. If you click a dataset variable in the list box of the Browse Data dialog box, detailed information about the dataset variable is displayed on the right-hand section of the dialog. For more information, refer to Viewing Variable Information.
11. When the equation is complete, click OK.

Note

If you entered an equation incorrectly, a warning message will appear and the equation identifier, Eqn, is displayed in the color red (if an equation is correct, this is displayed in the color black).

### Shortening Variable Names

When using variables in the default dataset, the dataset variable names can be shortened to make an equation easier to read, as long as each name remains unique. For example, if the variable is entered as:
Curve_Tracer.Sweep1.DC1.DC.IC.i

If this variable is in the default dataset, you can erase everything from the last period back and keep `IC.i`

If you want to use a variable with the same name, but from another dataset in the project, you cannot delete part of the name of either variable. Variable names must be unique.

If you enter data from datasets that are outside the project, the full file path is entered. You may want to keep the full path or you can erase the part of the file path that is common with the current project.

### Viewing Data From Multiple Datasets

The default dataset list only allows you to refer to a single dataset. If you have several equations you can easily change the referenced datasets by defining string variables with a dataset name and referring to the string variable in the equations. For example:

MeasuredData="measured"
MeasS21=db(\$MeasuredData..S(2, 1))
DiffS21=MeasS21 − SimS21
SimulatedData="simulated"
SimS21=db(\$SimulatedData..S(2, 1))

### Inserting Conditional Expressions

DDS Equation editor also allows you to enter conditional expressions. You can make use of if then else statement as shown in the following example:

```x = if (freq > 100 MHz) then .001 else 1e99
```

## Viewing Equation Results

Equation results can be plotted or displayed in a list. You treat results like any other data. You can apply markers, edit the format, or use the results of an equation within another equation.

To view the results of your equation:

1. Click the Equation button on the palette or choose Insert > Equation.
2. Position the pointer on the display area and click the mouse to display the Enter Equation dialog box.
3. Select Equations from the Datasets and Equations list.
4. Select the equation variable and click the Insert button.
If the equation is entered incorrectly, an error indication is displayed. Some types of equation errors cause the equation ( Eqn ) identifier on the Data Display to be highlighted in red. Other errors will cause the error dialog box to appear. This dialog box provides specific information about the error.
5. The default trace type for the chosen data will be used. If you want to verify or change the trace type, click Trace Options and proceed to edit the trace.
6. Click OK to dismiss the dialog box and display the equation results.

Equation results can also be displayed in text objects. For more information refer to Embedding Equations in Text Objects.

## Working with Multidimensional Data

It is not uncommon to sweep more than one parameter in a simulation. Data from such simulations is stored as multidimensional data. If you want to perform calculations on, or display only portions of the data from such simulations, you need to use equations to select the subsets of data.

The curve tracer example is used to illustrate how to do this. The example is under the Examples directory in the MW_Ckts subdirectory. From this subdirectory, open the project LNA_prj and then open the Curve_Tracer schematic that is part of this project.

To open the data display, from the curve tracer schematic window, choose Window > Open Data Display and select Curve_Tracer.dds.

Refer to the schematic. In this example the base current, IBB, and the collector-emitter voltage, VCE are swept in this manner: IBB is set to 5 mA, and VCE is swept from 0V to 3 V in 0.1 V steps. At each 0.1 V increment, IC is calculated and stored in the dataset. When this sweep is complete, IBB is increased to 5 mA, VCE is swept from 0V to 3V, and at every 0.1 V increment IC is measured and stored in the dataset. This is repeated until IBB equals 30 mA; a final sweep of VCE is performed and the simulation is complete.

Refer to the data display. The curve tracer is the entire collection of IC data points. This data is stored in the dataset, and the structure of how data is stored is described next.

Certain measurements, such as EVM in a DSP schematic window, treat each sweep point as a separate simulation and returns a single point of data. Each point of data contains the swept variable, simulation results, and an index of zero.
To display such data, create an expression such as my_evm = E [ : : , 0] to extract the zeroth index of the swept expression.

### Data Structure

Based on the simulation sweeps, there are six values for IBB and 31 values for VCE. The index for IBB is 0-5, the index for VCE is 0-30. For each of these combinations of VCE and IBB, IC was calculated and stored in the dataset.

It is possible to select a single point of data or a sequence of data. The next section describes how to access portions of data using indices.

### Accessing Data

Data is accessed by index values. The equation below returns the value of IC when VCE =0V and IBB =20 mA.

Type the equation and use a list to display your results. For information on how to enter equations, refer to Inserting Equations. For information on how to display equation results, refer to Viewing Equation Results.

For this equation, the order of the indices did not matter, but in general it does. The next section describes index order.

#### Index Order

Data is retrieved by the index values. The index order is critical to returning intended data, and it is based on how the simulation is set up. In the curve tracer simulation, the Parameter Sweep item references the DC Simulation item, and the DC simulation parameter ( VCE ) is swept based on the parameter-sweep parameter ( IBB ). The index order is outermost to innermost, so the index for IBB precedes the index of VCE.

Try retrieving other data points, such as:

x1=IC.i[1,0]
x2=IC.i[0,1]
x3=IC.i[1,30]

View the results in lists and compare your results to the data structure illustration.

### Accessing Sequences of Data

You can access subsets of data using indices. You can either specify the range, or use wild cards.
For example, to display only the trace for IBB = 20mA, type as an equation:

IBB20=IC.i[3,::]

Add IBB20 to the curve tracer plot to view the results.

The characters `::` in the equation are the wildcard. In this equation, the wildcard substitutes for a VCE index value, so all values of VCE are used and the entire trace of data is returned.

To display only a portion of the trace, use a sequence:

The data in the 10th through 20th elements are displayed. The default increment is 1, so this sequence could also be written as `10::20`. If you want to skip data points within the sequence, set the increment to a value larger than one.

Note

Try setting this trace to a Scatter trace type, then insert different increment settings in the equation to view the effects of the increment parameter.

To display a portion of several traces, use two sequences:

IBB20=IC.i[3::5,10::20]

Note the results on the curve tracer plot.

#### Accessing a Sweep of Data

You can return a sweep of data using a wildcard in the first position of the equation:

VCE5=IC.i[::,5]

This example returns the values of IC where VCE = 0.5V.

Do not plot this result on the existing curve tracer plot. Instead, insert a new plot and add the data to the new plot. The axes on this plot are different from the curve tracer. VCE is plotted along the y axis as a function of IBB, which is plotted along the x axis.

You can change the trace type from Linear to Scatter and see the individual data points.

You can also write the same equation as:

VCE5=IC.i[5]

The wildcard in the first position is assumed.

### Plotting Multidimensional Data

When you plot multidimensional data, the x-axis depends on whether the data is plotted using a single index value or using the wildcard (::) to select all index values.

The what() function returns the dimensions in the dataset entry and the number of points in each dimension. The following shows that the dimensions in BudGain1 are Component, X, and freq.

The following shows multidimensional data plotted using a single index value (0) for frequency:

Since frequency is a single index value, the x-axis value shifts left to the next dimension, which is X in this example.
The following shows the same multidimensional data plotted using the wildcard to select all index values for frequency:

Since frequency is all index values, the x-axis value is frequency. In this example, frequency was a single value so you may have expected the same results as shown using a single index value. However, the plotting routine does not make a distinction between the case where the wildcard represents one index value or multiple index values.

## Working with Swept S-parameters

If you want to access subsets of swept S-parameters, you need to use both index notation and S-parameter notation. This section describes the various combinations and the results that are returned.

### Setting up an Example

If you want to have an example to work with, set up and perform the simulation described here. Otherwise, skip to the next section.

This example adds a parameter sweep to the amplifier.dsn schematic in the project SweptSparams_prj.

1. From the Main window, click the Examples directory.
2. Select Tutorial.
3. Select SweptSparams_prj.
4. Choose File > Copy Project and make a copy of the project.
5. Open the copy of SweptSparams_prj.
6. Open the schematic amplifier.dsn.
7. Add a swept parameter by modifying the voltage source using a Var Eqn Data item and a parameter sweep item, as shown below.
8. Rerun the simulation. The simulation will run in this manner: Vbias is set to 3V and an S-parameter simulation is performed at each frequency specified in the S-parameter simulation item and the S matrixes are stored in the dataset; Vbias is set to 3.9 V and another set of S-parameter simulations are performed and stored in the dataset; this continues until Vbias equals 2.0 V, when a final set of S-parameter simulations are performed and the entire simulation is complete.
9. When the simulation is complete, open a new Data Display window.
10. Set the default dataset to amplifier.
11. Insert a rectangular plot and add S(2,1) to the plot. The entire collection of S(2,1) data points that were calculated for each frequency point and for each value of Vbias is displayed.

The next section describes how the data is stored in the dataset.

### Data Structure

Based on the simulation sweeps, there are eleven values for Vbias and 200 values for freq. The index for Vbias is 0-10, the index for freq is 0-199. For each of these combinations of Vbias and freq, an S matrix was calculated and stored in the dataset.

Index order is the same as described in Index Order. That is, the outermost index is first, innermost is last. In the example above, the first position is the index of Vbias, the second is for freq.

### Accessing Data

You can access S-parameters using indices. The equation below returns S21 calculated for Vbias =2.9 V and freq = 5 MHz:

myS21=S21[1,0]

Type the equation and use a list to display your results. For information on how to enter equations, refer to Inserting Equations. For information on how to display equation results, refer to Viewing Equation Results.

The equation below returns S21 at all frequencies for a single value of Vbias ( Vbias =2V):

S21at2V=S21[10,::]

Add this result to a plot. The wildcard `::` is used to substitute for a freq index, so all values of freq are returned, enabling you to display an entire trace of S21 results.

To display only a portion of the trace, use a sequence:

The data in the 50th through 199th elements are displayed. The default increment is 1, and the sequence could be written as `50::199`. If you want to skip data points within the sequence, set the increment to a value larger than one.

Hint

Try setting this trace to a Scatter trace type, then insert different increment settings, for example replace `1` with `20`, to view the effects of the increment parameter.

To display a portion of several traces, use two sequences:

S21block=S21[2::10,90::140]

Add this to the plot and note the results.

#### Accessing a Sweep of Data

You can return a sweep of data using a wildcard in the first position of the equation:

column=S21[::,80]

This example returns S21 for every value of Vbias at the frequency with index 80.
Do not plot this result on the existing curve tracer plot. Instead, insert a new plot and add the data to the new plot. The axes on this plot are different from the curve tracer. S21 is plotted along the y axis as a function of Vbias, which is plotted along the x axis.

You can change the trace type from Linear to Scatter and see the individual data points.

You can also write the same equation as:

column=S[80]

The wildcard in the first position is assumed.

### Working with an S Matrix

S-parameters are stored in an S matrix. In general, you will probably want to work with a specific S-parameter and not the entire matrix. You can, however, access an entire matrix. If you do not specify an S-parameter, an equation using S returns the entire S matrix:
myMatrix=S[1,0]

Note

If ellipsis points appear in the list of data, enlarge the list by selecting the list and dragging a handle horizontally until all values are displayed correctly.

You can also use indices in this way without specifying an S-parameter and return the S matrix at each point:
manyMatrices=S[2::5, 80::90]

Use a list to display your results. Use the scroll buttons to browse the entire list of data. As you can see, a large amount of data is returned.

## Viewing Variable Information

Use the what function to view information about a variable, including:

• Independent variables
• Number of data points
• Matrix size
• Data type, such as real or complex

If the variable contains a single number or a one-dimensional sequence of numbers (like a row or column) it is termed Scalar. If the data is two dimensional, it is termed a Matrix and the size of the matrix is given. Examples of two variables from the swept S-parameter example, Vbias and the S matrix, S, are shown below. For details about these variables, refer to Setting up an Example.

### Finding an Index

The amount of data in this simulation is two dimensional and relatively small, and it is not difficult to determine the swept parameter values that correspond to indices. For more complex problems, you can use the find_index() function. The find_index() function returns the index that corresponds to a data value. For example, in the Curve_Tracer example, VCE is a scalar that contains 61 points of data. The equation below returns the index when VCE is 3 V:

The find_index() function works only on scalar data. VCE is specified using indices in order to present it in scalar format.

## Using Markers in Equations

You can add marker labels to equations and perform operations on marker data. The operation is performed on the dependent marker data.

To add a marker to an equation:

1. Click the Equation button on the palette or choose Insert > Equation.
2. Position the pointer on the display area and click the mouse.
3. The Enter Equation dialog box appears. Type the equation.
4. At the point where you want to add the marker, choose Equations __ from the Datasets and Equations __ list.
5. Select the marker label and click Insert.
6. Complete the equation, then click OK.

You can treat markers like any other variable in an equation.

Note

If you change the marker label (which is accomplished by selecting the marker and choosing Edit > Item Options), you must edit your equations by deleting the old marker label and entering the new marker label.

### Using Independent Marker Data

You may want to retrieve the independent data in a marker. You can do this using the indep function. For example:
myequation=indep(m1)
where m1 is the marker label. You can also nest this within another function.

Markers on polar plots and Smith charts return data in complex format. You may want to work with only the imaginary portion of the number, which you can retrieve using the imag function. The illustration shown next shows a Smith chart, the marker applied to a trace, the equation used to isolate the imaginary component, and a list to verify the equation is correct.

## Generating a Histogram after Monte-Carlo Analysis

The example in this section demonstrates a simple histogram using data from the Tutorial/yldex1_prj example. The example simulates the frequency response of an impedance transformer, with component values varied during a yield analysis. For more information on generating a histogram, refer to Using Statistical Design.

###### Simple Histogram using data from the Tutorial/yldex1_prj Example
• The first plot in Simple Histogram using data from the Tutorial/yldex1_prj Example above shows all of the dB(S21) curves.
• The second plot shows the distribution of dB(S21) at one particular frequency, specified by the "freq_index" equation.
• The S21[::,freq_index] syntax selects the S21 values for all Monte Carlo iterations at the "freq_index" frequency.
• The NumBins variable just sets the number of histogram bins.

## Using Predefined Equations

Data Display has a set of predefined equations that you can use to display and document current data properties such as default dataset name and path.

The following table lists the predefined equations available:

Predefined Equation Name

Description

Default_Dataset_Name

The current default dataset name. This name does not include the ".ds" extension

Default_Dataset_Path

The full path to the directory that contains the default dataset

Default_Dataset_Modified_Time

Default_Dataset_Modified_Date

Default_Dataset_Size

The size in bytes of the default dataset

DDS_File_Name

The current DDS file name without the ".dds" extension

DDS_File_Path

The path to the directory that contains the current DDS file

DDS_File_Modified_Time

The last time the DDS file was modified

DDS_File_Modified_Date

The last date the DDS file was modified

DDS_File_Size

The size in bytes of the DDS file

You can display dataset information in two ways, using either a text object or a list.
To display dataset information in a text object refer to Embedding Dataset Properties in Text Objects.

To display dataset information in a list...

1. Select List from the palette or choose Insert > Plot, then click the mouse on the page to place the plot and display the Plot Traces & Attributes dialog box.
2. Select List in the Plot Type tab.
3. From the Datasets and Equations dropdown menu select Predefined Equations.
4. Use the dialog box to select and add data properties to the display.
• No labels