Create Signals with MATLAB Expressions and Variables - MATLAB & Simulink (2024)

Create Signals with MATLAB Expressions and Variables

The Signal Editor allows you to add signals using MATLAB® expressions and variables using the Author and Insert dialog box. In the Insert section, select Author Signal.

Create Signals with MATLAB Expressions and Variables- MATLAB & Simulink (1)

For a description of these parameters, see Author Signal.

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

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

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

Create Signals with MATLAB Expressions and Variables- MATLAB & Simulink (2)

To view the signal, cancel the Author and Insert dialog box, navigate to the Inputs pane, and double-click Create Signals with MATLAB Expressions and Variables- MATLAB & Simulink (3) for the new signal. If a signal has real and imaginary parts, both parts display in one plot. The tabular data editor also reflects the signal data.

Create Signals with MATLAB Expressions and Variables- MATLAB & Simulink (4)

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

If the data does not plot as expected, click Fit to view 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, click Data Cursors 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.

    Create Signals with MATLAB Expressions and Variables- MATLAB & Simulink (5)

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

    Create Signals with MATLAB Expressions and Variables- MATLAB & Simulink (6)

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

    Create Signals with MATLAB Expressions and Variables- MATLAB & Simulink (7)

    Zoom out from the graph.

    Create Signals with MATLAB Expressions and Variables- MATLAB & Simulink (8)

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

    Create Signals with MATLAB Expressions and Variables- MATLAB & Simulink (9)

    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.

    Create Signals with MATLAB Expressions and Variables- MATLAB & Simulink (10)

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]

Create Signals with MATLAB Expressions and Variables- MATLAB & Simulink (11)

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 (Create Signals with MATLAB Expressions and Variables- MATLAB & Simulink (12)). 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:

  • Timelinspace(0,10,11)

  • Data[0:10]

    Create Signals with MATLAB Expressions and Variables- MATLAB & Simulink (13)

See Also

Blocks

Tools

Related Topics

Create Signals with MATLAB Expressions and Variables
- MATLAB & Simulink (2024)
Top Articles
Latest Posts
Article information

Author: Corie Satterfield

Last Updated:

Views: 5920

Rating: 4.1 / 5 (42 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Corie Satterfield

Birthday: 1992-08-19

Address: 850 Benjamin Bridge, Dickinsonchester, CO 68572-0542

Phone: +26813599986666

Job: Sales Manager

Hobby: Table tennis, Soapmaking, Flower arranging, amateur radio, Rock climbing, scrapbook, Horseback riding

Introduction: My name is Corie Satterfield, I am a fancy, perfect, spotless, quaint, fantastic, funny, lucky person who loves writing and wants to share my knowledge and understanding with you.