Main Content

Create Signals with MATLAB Expressions and Variables

To add signals using MATLAB® expressions and variables, select the Signal Editor Signal > Author Signal option.

  • Time — Enter the range of time for the data.

  • Data — Enter the MATLAB expression for the signal.

  • Data type — Select or enter the signal data type.

    • double

    • single

    • int8

    • uint8

    • int16

    • uin16

    • int32

    • uint32

    • boolean

    • fixdt(1,16)

    • fixdt(1,16,0)

    • fixdt(1,16,2^0,0)

    • string

    • Enum: <class name>

    If you enter your time and data and then select a fixed-point data type, the Signal Editor displays a fixed-point proposed data type for your data.

    • To help you select a fixed-point data type, click the Show Histogram button (). Clicking this button displays a plot of the signal data using the selected fixed-point data type. The graph displays:

      ColumnInformation
      ValuesThe negative, positive, and zero signal values.
      Potential OverflowsBins the signal values that may overflow.
      In-RangeBins the signal values that are within acceptable range.
      Potential UnderflowsBins the signal values that may underflow.

      To see the difference that a data type may have on the histogram, select:

      • User Specified

      • Binary Scaling

      • Slope & Bias Scaling

      For more information, see Histogram Plot of Signal (Fixed-Point Designer).

    • To apply the proposed fixed-point data type to your data, click the Use proposed data type button ().

When you click Insert Signal, the interface evaluates the signal, updates the signal information in the dialog box, and adds the signal to the Scenarios and Signals section. In addition, the number of samples, signal data type, and signal dimension also appear.

To see example Time and Data entries, click the Show Examples button. To experiment with the signals from these example signal notations, click the Apply Example button for the associated example. You can also modify the examples before inserting.

For example, to create a sine wave, click the Apply Example button next to that example and click the Insert Signal button. Observe that dialog box displays the number of samples, signal data type, and signal dimensions.

To view the signal, cancel the Author and Insert dialog box, navigate to the Scenarios and Signals section, and click the Plot/Edit button for the new signal. If a signal has real and imaginary parts, both parts display in one plot. The tabular editor also reflects the signal data.

Explore the plots using the plot context menus Align and Zoom & Pan.

If the data does not plot as expected, use the Fit to view button in the Zoom & Pan section. For multidimensional signals, also make sure that you have the right plot selected for the column data you are editing.

  • In the Measure section, use the Data Cursors button to display one or two cursors for the plot. These cursors display the T and Y values of a data point in the plot. To view a data point, click a point on the plot line.

  • In the Zoom & Pan section, select how you want to zoom and pan the signal plots. Zooming is only for the selected axis.

    Type of Zoom or PanButton to Click

    Zoom in along the T and Y axes.

    Zoom in along the time axis. After selecting the icon, on the graph, drag the mouse to select an area to enlarge.

    Zoom in along the data value axis. After selecting the icon, on the graph, drag the mouse to select an area to enlarge.

    Zoom out from the graph.

    Fit the plot to the graph. After selecting the icon, click the graph to enlarge the plot to fill the graph.

    Pan the graph up, down, left, or right. Select the icon. On the graph, hold the left mouse button and move the mouse to the area of the graph that you want to view.

Tip

To produce signals with linearly spaced values for time, use the linspace function, for example:

  • Timelinspace(0,10,101)

  • Data[0:0.1:10]

To edit signal data without using MATLAB expressions, see Work with Basic Signal Data.

Replace Signal Data with MATLAB Expressions

You can replace signal data using MATLAB expressions at any time, regardless of how you created the original signal data. To replace signal data, select that signal in the Scenarios and Signals section, and then click the replace button (). Use the Author and Replace Signal Data dialog box as if you were inserting a new expression with the Author and Insert dialog box. For more information, see Create Signals with MATLAB Expressions and Variables.

Note

You cannot change data types to or from a fixed-point data type.

Tip

When replacing a signal, the signal dimension and complexity of the new signal must be the same as the signal being replaced.

Tip

To produce signals with linearly spaced values for time, use the linspace function. For example, using:

  • Timelinspace(0,10,11)

  • Data[0:10]

See Also

|

Related Topics