Create and Edit Signal Data - MATLAB & Simulink (original) (raw)

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. By default, Signal Editor creates signal data in timeseries format. You can access the Signal Editor in the following ways:

Signal Editor works only with MAT-files.

You can manipulate signals in these ways:

While editing signal data:

Alternatively, you can:

To graphically create and edit signal data, see Create Freehand Signal Data Using Mouse or Multi-Touch Gestures.

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:

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.

Add and Edit Multidimensional Signals

To add multidimensional signals, use either of these options:

When you double-click show/hide for the signal, the tabular data area displays the signal with columns for each dimension. You can edit the data individually in the tabular data area, cut, copy, or replace data with Excel spreadsheets, 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, seeCreate 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 Signal Editor, select > .
  2. Enter signal data with two columns and time from 1 to 10:
    • Time[1:10]
    • Data[(1:10)' (1:10)']
      ![Author and Insert dialog box with time = [1:10] and data = (1:10)' (1:10)'
  3. Click Insert Signal.
    The hierarchy updates with the new signal data.
  4. Expand the new signal and double-click show/hide for the signal. Observe the associated plots and the tabular data for the signal.
    Hierarchy and plot of time = [1:10] and data = [(1:10)' (1:10)']
    Tip
    If the data does not plot as expected, click Fit to view in theZoom & 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.
    Hierarchy and plot with time = 4, data(;,1)=10, data(;,2)=4
    To replace data completely with a new expression by clickingReplace and entering a new time range and data in the Author and Replace Signal Data dialog box.
    Tip
    Selecting a point in the plot highlights the associated data in the table. Vice versa, selecting a data point in the table highlights the associated point in the plot.
    Deleting a point in the plot deletes the associated data in the table. Vice versa, deleting a data point in the table deletes the associated point in the plot.
  6. To synchronize all the signals in open plots by time (_x_-axis), select Synchronize X-limits in the Synchronize.SignalX Axes Properties pane. Use this setting to also synchronize zooming, panning, and fit-to-plot.

Change _x_- and _y_-axes Limits

Change plot _x_- and _y_-axes limits in theSignalX.Scenario Axes Properties panes. When you change the limit, the plot adjusts your view.

For example, look at this plot and SignalX.Scenario Axes Properties pane. The rightmost limit of the _x_-axis is 11.037.

Plot of Signal.Scenario Axes Properties before a change. The original rightmost limit of the x-axis limit is 11.037.

The data in this plot is the same, but the plot has a rightmost _x_-axis limit of 9.

Plot of Signal.Scenario Axes Properties after a change. The adjusted rightmost limit of the x-axis limit is 9.

Change Signal Data Output Format Settings

By default, the Signal Editor tool displays signal data in its data pane as double, with a format that displays integers as whole numbers (auto).

Hierarchy and plot of time = [1:10] and data = [(1:10)' (1:10)'] and display format auto

Floating-point and fixed-point data types display with their least significant digits.

To change display time and signal data formats in the Signal Editor tool, use the Display Format pane. You can change the display format for time and data. The Signal Editor tool preserves the display format settings acrossSignal Editor sessions. For example, to change the time and format display to use a formatting operator, for Time and Floating point in Display Format, select %5.3g. You can change the formatting operator as necessary. The Signal Editor tool remembers the last five unique formatting operators.

Hierarchy and plot of time = [1:10] and data = [(1:10)' (1:10)'] and display format %5.3g

The effect of the associated display format fields depends on the data type. For example, if the data type is double, setting Fixed point has no effect.

Hierarchy and plot of time = [1:10] and data = [(1:10)' (1:10)'] and display format %5.3g, data type double

However, if the data type of this data is changed to a fixed-point value, then theFixed point takes effect.

Hierarchy and plot of time = [1:10] and data = [(1:10)' (1:10)'] and display format %5.3g, data type fixed-point

For more information on display formats, see Format Output and Formatting Text.

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 > .
  2. Expand the new signal and double-click show/hide for the signal. Observe the associated plots and the tabular data for the signal.
  3. In the Edit tab, to line up the signal data values along horizontal and vertical lines, select > and > .
    Move and zoom also honor snap to grid settings.
  4. In the canvas, use Erase to erase the second point.
  5. 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
  6. In the Signal Properties section, in Name, change the signal name to Ramp and press Enter.
    Signal properties shows name Ramp name.

Save and Send Changes to the Root Inport Mapper Tool

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

See Also

Blocks

Tools

Functions

Topics