Create and Edit Signal Data

Use the Signal Editor to create and edit input signals that you can organize for multiple simulations. You can then save the signal data to a MAT-file for simulation or to map to root-level ports. You can access the Signal Editor in the following ways:

  • signalEditor function — Signal Editor starts from the command line.

  • From the Root Inport Mapper — To create a MAT-file for your new signal data, select Signals > New MAT-File. To link in an existing signal data file from an existing scenario and edit the signals in that file, use the Signals > Edit MAT-File.

  • From the Signal Editor block

Signal Editor works only with MAT-files.

You can manipulate signals in these ways:

  • Create and edit multiple signals in multiple data sets.

  • Use signal notations to create more complicated signals using MATLAB® expressions.

  • Use existing scenarios to get existing data sets for which you can edit and create signals.

  • Create and edit multidimensional signals.

  • Edit signals imported as registered custom file types. For more information, see Import Custom File Type.

While editing signal data:

  • Use tabular editing or MATLAB to modify signal data.

  • Modify signal properties such as name, interpolation, and unit properties.

  • Drag and drop signals to change signal hierarchies for buses and data sets.

  • Use signal notations and variables to replace signal data.

Alternatively, you can import data from external sources and edit them in Signal Editor. For more information, see Link in Signal Data from Signal Builder Block and Simulink Design Verifier Environment.

Differences Between the Root Inport Mapper Signal Editor and Other Signal Editors

Generally, the Signal Editor user interface is the same regardless of how you access it. Here are the differences in the Root Inport Mapper Signal Editor:

  • FILE section Save and Sync and SAVE commands save and synchronize to the Root Inport Mapper.

  • Insert section Scenario command always has the option, Scenario from Model.

If you start the function with a model name, the signalEditor function Signal Editor user interface shows the option Scenario from Model in the Insert section.

Table Editing Data Support

The Signal Editor user interface supports all signal data types that Simulink® supports and that are editable.

Mouse, Keyboard, and Touchscreen Shortcuts

Edit actions:

ActionKeyboardMouseMulti-Touch

Insert point

Ctrl+P

Click

Tap

Insert line

Ctrl+L

Click

Pan and pinch

Draw

Ctrl+D

Click and draw

Pan

Select a point

Ctrl+T

Click , then click and select point or area

To select all areas, double-click

Pan and pinch

To select all areas, double-tap

Move a point

Ctrl+M

Click and drag

Tap and move

Change data of a point 

Click

 
Continuously delete points on a line 

Click Erase icon

 
  

Three mouse clicks

Triple tap

Expand along the x-axis 

Ctrl+mouse pan

Pry x-axis

Expand along the y-axis 

Shift+mouse pan

Pry y-axis

Zoom actions:

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 only in x while zooming in xy.

Zoom in xy while pressing Ctrl

Zoom only in y while zooming in xy.

Zoom in xy while pressing Shift

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.

Change Signal Names and Hierarchy Orders

In the Scenarios and Signals section, you can change signal names and hierarchy order, create duplicates of signals, and delete signals. Simulink ignores leading and trailing spaces in signal names.

  • To change a signal name, double-click the name and change it.

  • To change the unit or interpolation of a signal, click the plus sign and click the Unit or Interpolation check boxes.

    The pane updates with Unit and Interpolation columns.

    • In the Unit column, enter an appropriate unit expression. For a suggested list of unit expressions, see allowed units.

    • In the Interpolation column, from the drop-down list, select linear or zero order hold.

      Note

      Interpolation affects only the plotting of signals in the Signal Editor user interface.

  • To change the order of a signal in the hierarchy, drag and drop it. For example, you can drag and drop signals into a bus.

    Alternatively, use the Move Up and Move Down buttons in the Adjust section.

  • To copy a signal and paste it under the original, right-click it and select Duplicate Signal.

    Alternatively, use the Duplicate button in the Adjust section. You can also adjust the default properties of the signal you duplicate. For more information, see Create Signals with the Same Properties.

  • To copy a signal and paste it elsewhere in hierarchy, select Copy and then Paste.

Create Signals with the Same Properties

To create signals of the same predefined type, use the Duplicate button in the Adjust section. To change the predefined signal type, click the Defaults icon, . A Default Properties for Insertion dialog box displays.

  • Data type — From the drop-down list, select the signal data type.

  • Enumeration — When you select the Enum data type, this parameter displays. Enter the class name of your enumeration.

    If you define an enumeration class that contains the same integer value multiple times, for example:

    classdef(Enumeration) hEnumColors_duplicateValues < Simulink.IntEnumType
      enumeration
        Red(118)
        Yellow(-14)
        Blue(90)
        Green(87)
        White(-14)
        Black(198)
        Brown(90)
        Pink(118)
        Purple(90)
      end
      methods (Static = true)
        function retVal = getDefaultValue()
          retVal = hEnumColors_duplicateValues.Blue;
        end
      end
    end
    

    The Signal Editor treats the first enumeration value (Red (118)) as the canonical value and equates all subsequent instances of the same underlying integer 118 to the enumerated name Red. In other words, Pink equals Red.

  • Interpolation — From the drop-down list, select linear or zero order hold.

  • Unit — Enter an appropriate unit expression. For a suggested list of unit expressions, see Allowed Units.

  • Dimensions — Enter the number of dimensions for the signal.

  • Signal type — From the drop-down list, select real or complex.

  • Bus object — From the drop-down list, select the bus object for which to define the dimensions. If you leave the Bus object parameter at the default <object name>, Signal Editor adds empty buses.

  • Dimensions — Enter the number of dimensions for the bus object.

Add and Edit Multidimensional Signals

To add multidimensional signals, use either of these options:

  • Change the Dimensions property in the Default Properties for Insertion dialog box, and then use Insert > Blank Signal to insert a new blank signal. For a multidimensional blank signal, enter a dimension greater than 1.

  • Enter multidimensional signal data in the Author and Insert dialog box Data parameter, such as [(1:10)' (1:10)'].

When you click the Plot/Edit check box for the signal, the tabular area displays the signal with columns for each dimension. You can edit the data individually in the tabular area, or click the replace button to replace the signal with a MATLAB expression. Use the Author and Replace Signal Data dialog box as though you are inserting a new expression with the Author and Insert dialog box. For more information, see Create Signals with MATLAB Expressions and Variables.

Tip

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

For example, to create signal data with two columns and time from 1 to 10:

  1. In the Signal Editor, select Signal > Author Signal.

  2. Enter signal data with two columns and time from 1 to 10:

    • Time[1:10]

    • Data[(1:10)' (1:10)']

  3. Click Insert Signal.

    The hierarchy updates with the new signal data.

  4. Expand the new signal and click the Plot/Edit check boxes for the new signal data. Observe the associated plots and the tabular data for the signal.

    Tip

    If the data does not plot as expected, use the Fit to window 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.

  5. You can edit the data directly in the table.

    Or you can replace data completely with a new expression by clicking the Replace button and entering a new time range and data in the Author and Replace Signal Data dialog box.

Work with Data in Signals

This example describes how to add and delete data to the signals in the linked scenario. To create a model and data to work with, see Add Signals to Scenarios.

  1. In the Signal Editor, in the Scenarios and Signals section, click the plot check box for the signal ts.

  2. Add some data to the signal ts.

    1. Click the add row icon and add some signals. To add a signal row between other signals, click the signal before and click the add row icon.

    2. When done, click Apply. Clicking Apply updates the plot.

  3. Remove the time 20 line from the signal. Select 20 and click .

  4. Alternatively, if you want to replace all the signal data for ts with a signal defined with signal notations, click the replace button and use the Author and Replace Signal Data dialog box to define new data.

Draw a Ramp Using Snap to Grid for Accuracy

This example describes how to create a ramp signal by selecting some points in the canvas.

  1. In the Signal Editor tab, select Signal > Draw Signal.

  2. To line up the signal data values along horizontal and vertical lines, select Snap X to Grid and Snap Y to Grid.

  3. In the canvas, add three points:

    • Two points horizontal to each other

    • One point set to the right at an angle to the other signals

  4. In the Signal Properties section, in Name, change the signal name to Ramp and press Enter.

  5. To add the signal to the Signal Editor, in the Insert section, click .

  6. To return to the main Signal Editor window and check that the signal has been added, click .

  7. To observe the drawn signal data In Signal Editor, click the Plot/Edit check box for the Ramp signal name in the hierarchy.

Save and Send Changes to the Root Inport Mapper Tool

When you are done adding and modifying signals and scenarios, use the Save and Sync button to save the changes to a MAT-file. The Signal Editor also sends the data to the Root Inport Mapper Tool:

  • If the Root Inport Mapper tool has the scenario loaded, the Root Inport Mapper tool updates with the new data.

  • If the Root Inport Mapper tool has the scenarios mapped and your changes affect the mapping, the Root Inport Mapper tool unmaps the scenario.

See Also

| | |

Related Topics