Documentation

Create and Edit Signal Data

Use the Signal Editor user interface 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:

  • Create and edit multiple signals in multiple data sets.

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

While editing signal data:

  • Use tabular editing 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.

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 Signal Editor User Interfaces

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.

The signalEditor function Signal Editor user interface shows the option Scenario from Model in the INSERT section if you start the function with a model name.

Signal Editor Table Editing Limitations

These capabilities are currently not supported:

Limitation DescriptionWorkaround

Multidimensional and fixed-point signal data is not editable

Edit the multidimensional and fixed-point signal data in the MATLAB® base workspace, then import the data as a scenario to Signal Editor.

MATLAB expressions such as sin and cos are not supported.

Create function-generated signals in the MATLAB base workspace, then import the contents of the base workspace to the Signal Editor.

Link in Signal Data from Signal Builder Block and Simulink Design Verifier Environment

You can use Signals > Edit MAT-File to link in MAT-file data from these sources for editing.

Link in Data from Signal Builder

You can link in and edit data exported from the Signal Builder block in a MAT-file or MATLAB. Use one of these methods to export the data:

  • Signal Builder block File > Export Data > To MAT-file option, then link in the MAT-file.

  • signalbuilder get function with data sets, then perform either of these steps:

    • Import the data sets in the workspace and save to a MAT-file

    • Save the data sets in the workspace to a MAT-file and import the MAT-file

For more information on exporting from a Signal Builder block, see Exporting Signal Group Data.

Link in Test Vectors from Simulink Design Verifier Environment

You can link in and edit Simulink Design Verifier test vectors. This workflow requires a Simulink Design Verifier license.

Before linking in, use the Simulink Design Verifier sldvsimdata function to convert a Simulink Design Verifier test structure to a Simulink.SimulationData.Dataset object. This file contains a test vector structure sldvData. Save the output to a MAT-file and then import that file into Signal Editor.

Create Signal Data

Create signal data either from existing model data (scenarios), start with an empty scenario, or immediately start creating signals.

After inserting the signal, view and plot the data by clicking the PLOT check box.

Use Scenarios

Signal Editor uses scenarios to group and organize sets of inputs to be saved to a MAT-file for a single simulation. To create signal data using existing data sets from existing scenarios, or create an empty scenario into which to add signals, use the Signal Editor Scenario menu.

ActionOption

To create a scenario from the root inports of a model

Select Scenario > Scenario from Model. (Available only when accessing Signal Editor from the Root Inport Mapper.)

Note

When using this option, the resulting scenario contains signals with the data types and dimensions of the inport ports.

Alternatively, use the signaleditor function with a model argument.

To create an empty scenario and create signals from scratch

Select Scenario > Blank Scenario.

To import scenarios from MATLAB workspace

Select Scenario > From Workspace.

After you have your scenario:

Insert Signals

To insert signals into scenarios or just to a list of signals, select the scenario, then click a signal type from the INSERT section.

  • Signal

  • Bus

  • Ground

  • Function Call

    If you need a function-call signal for a root inport with explicit periodic sample time, insert a ground signal instead. Simulink then executes the function-call automatically.

The new signals appear in the SCENARIOS AND SIGNALS section.

You can also insert multiple signals of the same type. For more information, see Create Signals with the Same Properties.

To change the signal order in the hierarchy or change the name of a signal, see Change Signal Names and Hierarchy Orders.

To edit the properties of a signal, see Work with Signal Data.

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 dropdown list, select linear or zero order hold.

  • 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 duplicate a signal, 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.

Work with Signal Data

To edit signal data, select a signal and click the associated Plot check box. A plot of the signal displays. Under the signal plot is a tabular editor.

  • To insert or delete a data row for a signal, use or , respectively.

  • To change the data type for signal data, select the type from the pull-down.

  • To change the time or data for each signal, edit the associated column of the data row, then click Apply to update the plot of the signal.

  • To change the size of the plot or tabular area, move the separator up and down.

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 dropdown 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 dropdown 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 dropdown list, select real or complex.

  • Bus object — From the dropdown 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 Signals to Scenarios

This example describes how to create a scenario to be linked to from the Root Inport Mapper tool. You can then start the Signal Editor to manipulate and add signals to this scenario.

  1. In the MATLAB Command Window, create some data by typing:

    ts = timeseries([0;20],[0;10]); 
  2. In Simulink Editor, create a model that contains three Inport blocks, three Gain blocks, a Mux block, and a Scope block. Connect these blocks as shown:

  3. Set the gain for the Gain blocks to 5, 10, and 15, respectively.

  4. Click one of the Inport blocks, then click the Connect Input button.

    The Root Inport Mapper tool displays.

  5. In Root Inport Mapper LINK section, select From Workspace.

  6. In the From Workspace window, enter a name to store the MAT-file, then click OK.

  7. In the SCENARIO section of the Signal Editor, click Signals > Edit MAT-File.

  8. In the Edit Signal File window, select the new MAT-file and click OK.

    The Signal Editor displays.

  9. Add a signal, Signal, to the scenario. Right-click the scenario and select Insert > Signal.

    This action adds Signal with these default properties.

    Alternatively, insert signals by clicking a signal type from the INSERT section.

  10. Change the default properties of signals you want to add. In the INSERT section, select Defaults. In the Default Properties for Insertion dialog box, change the data type to boolean, then right-click the scenario and select Insert > Signal.

    This action adds Signal1 with the data type boolean.

  11. To check that the data type is boolean, click the plot check box for Signal1.

To add data for these signals, see Work with Data in Signals.

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 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 .

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 Examples

More About

Was this topic helpful?