Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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.

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 Limitations

The Signal Editor user interface supports all signal data types that Simulink® supports, with the exception that fixed-point signal data is not editable.

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 set of Simulink.SimulationData.Dataset objects. This file contains a test vector structure sldvData. Save the output to a MAT-file and then import that file into Signal Editor.

Use Scenarios to Group and Organize Inputs

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

You can also use the signaleditor function with a model argument.

Note

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

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, select the scenario, then click a signal type from the Insert section.

  • Signal

    Use the Signal split button to specify how you want to define the signal data:

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

Create Signals and Signal Data

Create signal data either from existing model data (scenarios) or start with an empty scenario. To a scenario, add signals and data by:

After inserting the signal, view and plot the data by clicking the Plot/Edit check box.

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.

Work with Basic Signal Data

To add and edit basic signal data, select a signal and click the associated Plot/Edit 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 drop-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.

  • To create multidimensional signals, use one of these methods. For more information, see Add and Edit Multidimensional Signals.

    • In the Default Properties for Insertion dialog box, enter a dimension greater than 1 in the Dimensions parameter.

    • In the Author and Insert dialog box, enter a MATLAB that creates multidimensional signals in the Data parameter

Instead of using the tabular editor to define signal data, you can use MATLAB expressions.

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.

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.

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.

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.

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.

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.

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]

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

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

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

    This action adds Signal with these default properties.

    Alternatively, insert signals by clicking a signal type from the Insert section or using the Signal split button to author a signal using signal notations.

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

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.

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

Was this topic helpful?