Working with Signal Groups

About the Signal Groups

The Signal Builder block allows you to create interchangeable groups of signal sources and quickly switch the groups into and out of a model. Signal groups can greatly facilitate testing a model, especially when used in conjunction with Simulink®'s Assertion blocks and Simulink Verification and Validation's Model Coverage Tool. For a description of the Model Coverage Tool, see the Simulink Verification and Validation User's Guide on The MathWorks™ Web site.

Creating a Signal Group Set

To create an interchangeable set of signal groups:

  1. Drag an instance of the Signal Builder block from the Simulink Sources library and drop it into your model.

    By default, the block represents a single signal group containing a single signal source that outputs a square wave pulse.

  2. Use the block's signal editor (see Signal Builder Dialog Box) to create additional signal groups, add signals to the signal groups, modify existing signals and signal groups, and select the signal group that the block outputs.

  3. Connect the output of the block to your diagram.

    The block displays an output port for each signal that the block can output.

You can create as many Signal Builder blocks as you like in a model, each representing a distinct set of interchangeable groups of signal sources. See Simulating with Signal Groups for information on using signal groups in a model.

Signal Builder Dialog Box

The Signal Builder block's dialog box allows you to define the waveforms of the signals output by the block. You can specify any waveform that is piecewise linear.

To open the dialog box, double-click the block. The Signal Builder dialog box appears.

The Signal Builder dialog box allows you to create and modify signal groups represented by a Signal Builder block. The Signal Builder dialog box includes the following controls.

Group Panes

Displays the set of interchangeable signal source groups represented by the block. The pane for each group displays an editable representation of the waveform of each signal that the group contains. The name of the group appears on the pane's tab. Only one pane is visible at a time. To display a group that is invisible, select the tab that contains its name. The block outputs the group of signals whose pane is currently visible.

Signal Axes

The signals appear on separate axes that share a common time range (see Signal Builder Time Range). This allows you to easily compare the relative timing of changes in each signal. The Signal Builder automatically scales the range of each axis to accommodate the signal that it displays. Use the Signal Builder's Axes menu to change the time (T) and amplitude (Y) ranges of the selected axis.

Signal List

Displays the names and visibility (see Editing Signals) of the signals that belong to the currently selected signal group. Clicking an entry in the list selects the signal. Double-clicking a signal's entry in the list hides or displays the signal's waveform on the group pane.

Selection Status Area

Displays the name of the currently selected signal and the index of the currently selected waveform segment or point.

Waveform Coordinates

Displays the coordinates of the currently selected waveform segment or point. You can change the coordinates by editing the displayed values (see Editing Waveforms).

Name

Name of the currently selected signal. You can change the name of a signal by editing this field (see Renaming a Signal).

Index

Index of the currently selected signal. The index indicates the output port at which the signal appears. An index of 1 indicates the topmost output port, 2 indicates the second port from the top, and so on. You can change the index of a signal by editing this field (see Changing a Signal's Index).

Help Area

Displays context-sensitive tips on using Signal Builder dialog box features.

Editing Signal Groups

The Signal Builder dialog box allows you to create, rename, move, and delete signal groups from the set of groups represented by a Signal Builder block.

Creating and Deleting Signal Groups

To create a signal group, you must copy an existing signal group and then modify it to suit your needs. To copy an existing signal group, select its tab and then select Copy from the Signal Builder's Group menu. To delete a group, select its tab and then select Delete from the Group menu.

Renaming Signal Groups

To rename a signal group, select the group's tab and then select Rename from the Signal Builder's Group menu. A dialog box appears. Edit the existing name in the dialog box or enter a new name. Click OK.

Moving Signal Groups

To reposition a group in the stack of group panes, select the pane and then select Move Right from the Signal Builder's Group menu to move the group lower in the stack or Move Left to move the pane higher in the stack.

Editing Signals

The Signal Builder dialog box allows you to create, cut and paste, hide, and delete signals from signal groups.

Creating Signals

To create a signal in the currently selected signal group, select New from the Signal Builder's Signal menu. A menu of waveforms appears. The menu includes a set of standard waveforms (Constant, Step, etc.) and a Custom waveform option. Select one of the waveforms. If you select a standard waveform, the Signal Builder adds a signal having that waveform to the currently selected group.

If you select Custom, a custom waveform dialog box appears.

The dialog box allows you to specify a custom piecewise linear waveform to be added to the groups defined by the Signal Builder block. Enter the custom waveform's time coordinates in the Time values field and the corresponding signal amplitudes in the Y values field. The entries in either field can be any MATLAB® expression that evaluates to a vector. The resulting vectors must be of equal length. Click OK. The Signal Builder adds a signal having the specified waveform to the currently selected group.

Copying and Pasting Signals

To copy a signal from one group and paste it into another group as a new signal:

  1. Select the signal you want to copy.

  2. Select Copy from the Signal Builder's Edit menu or click the corresponding button from the toolbar.

  3. Select the group into which you want to paste the signal.

  4. Select Paste from the Signal Builder's Edit menu or click the corresponding button on the toolbar.

To copy a signal from one axes and paste it into another axes to replace its signal:

  1. Select the signal you want to copy.

  2. Select Copy from the Signal Builder's Edit menu or click the corresponding button from the toolbar.

  3. Select the signal on the axes that you want to replace.

  4. Select Paste from the Signal Builder's Edit menu or click the corresponding button on the toolbar.

Deleting Signals

To delete a signal, select the signal and choose Delete or Cut from the Signal Builder's Edit menu. As a result, Simulink deletes the signal from the current group. Since each signal group must contain the same number of signals, Simulink also deletes all signals sharing the same index in the other groups.

Renaming a Signal

To rename a signal, select the signal and choose Rename from the Signal Builder's Signal menu. A dialog box appears with an edit field that displays the signal's current name. Edit or replace the current name with a new name. Click OK. Or edit the signal's name in the Name field in the lower-left corner of the Signal Builder dialog box.

Changing a Signal's Index

To change a signal's index, select the signal and choose Change Index from the Signal Builder's Signal menu. A dialog box appears with an edit field containing the signal's existing index. Edit the field and select OK. Or select an index from the Index list in the lower-left corner of the Signal Builder window.

Hiding Signals

By default, the Signal Builder dialog box displays the waveforms of a group's signals in the group's tabbed pane. To hide a waveform, select the waveform and then select Hide from the Signal Builder's Signal menu. To redisplay a hidden waveform, select the signal's Group pane, then select Show from the Signal Builder's Signal menu to display a menu of hidden signals. Select the signal from the menu. Alternatively, you can hide and redisplay a hidden waveform by double-clicking its name in the Signal Builder's signal list (see Signal List).

Editing Waveforms

The Signal Builder dialog box allows you to change the shape, color, and line style and thickness of the signal waveforms output by a signal group.

Reshaping a Waveform

The Signal Builder dialog box allows you to change the shape of a waveform by selecting and dragging its line segments and points with the mouse or arrow keys or by editing the coordinates of segments or points.

Selecting a Waveform.   To select a waveform, left-click the mouse on any point on the waveform.

The Signal Builder displays the waveform's points to indicate that the waveform is selected.

To deselect a waveform, left-click any point on the waveform graph that is not on the waveform itself or press the Esc key.

Selecting points.   To select a point of a waveform, first select the waveform. Then position the mouse cursor over the point. The cursor changes shape to indicate that it is over a point.

Left-click the point with the mouse. The Signal Builder draws a circle around the point to indicate that it is selected.

To deselect the point, press the Esc key.

Selecting Segments.   To select a line segment, first select the waveform that contains it. Then left-click the segment. The Signal Builder thickens the segment to indicate that it is selected.

To deselect the segment, press the Esc key.

Moving Waveforms.   To move a waveform, select it and use the arrow keys on your keyboard to move the waveform in the desired direction. Each key stroke moves the waveform to the next location on the snap grid (see Snap Grid) or by 0.1 inches if the snap grid is not enabled.

Dragging Segments.   To drag a line segment to a new location, position the mouse cursor over the line segment. The mouse cursor changes shape to show the direction in which you can drag the segment.

Press the left mouse button and drag the segment in the direction indicated to the desired location. You can also use the arrow keys on your keyboard to move the selected line segment.

Dragging points.   To drag a point along the signal amplitude (vertical) axis, move the mouse cursor over the point. The cursor changes shape to a circle to indicate that you can drag the point. Drag the point parallel to the y-axis to the desired location. To drag the point along the time (horizontal) axis, press the Shift key while dragging the point. You can also use the arrow keys on your keyboard to move the selected point.

Snap Grid.   Each waveform axis contains an invisible snap grid that facilitates precise positioning of waveform points. The origin of the snap grid coincides with the origin of the waveform axis. When you drop a point or segment that you have been dragging, the Signal Builder moves the point or the segment's points to the nearest point or points on the grid, respectively. The Signal Builder's Axes menu allows you to specify the grid's horizontal (time) axis and vertical (amplitude) axis spacing independently. The finer the spacing, the more freedom you have in placing points but the harder it is to position points precisely. By default, the grid spacing is 0, which means that you can place points anywhere on the grid; i.e., the grid is effectively off. Use the Axes menu to select the spacing that you prefer.

Inserting and Deleting points.   To insert a point, first select the waveform. Then hold down the Shift key and left-click the waveform at the point where you want to insert the point. To delete a point, select the point and press the Del key.

Editing Point Coordinates.   To change the coordinates of a point, first select the point. The Signal Builder displays the current coordinates of the point in the Left Point edit fields at the bottom of the Signal Builder dialog box. To change the amplitude of the selected point, edit or replace the value in the Y field with the new value and press Enter. The Signal Builder moves the point to its new location. Similarly edit the value in the T field to change the time of the selected point.

Editing Segment Coordinates.   To change the coordinates of a segment, first select the segment. The Signal Builder displays the current coordinates of the endpoints of the segment in the Left Point and Right Point edit fields at the bottom of the Signal Builder dialog box. To change a coordinate, edit the value in its corresponding edit field and press Enter.

Changing the Color of a Waveform

To change the color of a signal waveform, select the waveform and then select Color from the Signal Builder's Signal menu. The Signal Builder displays the MATLAB color chooser. Choose a new color for the waveform. Click OK.

Changing a Waveform's Line Style and Thickness

The Signal Builder can display a waveform as a solid, dashed, or dotted line. It uses a solid line by default. To change the line style of a waveform, select the waveform, then select Line Style from the Signal Builder's Signal menu. A menu of line styles pops up. Select a line style from the menu.

To change the line thickness of a waveform, select the waveform, then select Line Width from the Signal menu. A dialog box appears with the line's current thickness. Edit the thickness value and click OK.

Signal Builder Time Range

The Signal Builder's time range determines the span of time over which its output is explicitly defined. By default, the time range runs from 0 to 10 seconds. You can change both the beginning and ending times of a block's time range (see Changing a Signal Builder's Time Range).

If the simulation starts before the start time of a block's time range, the block extrapolates its initial output from its first two defined outputs. If the simulation runs beyond the block's time range, the block by default outputs values extrapolated from the last defined signal values for the remainder of the simulation. The Signal Builder's Simulation Options dialog box allows you to specify other final output options (see Signal values after final time for more information).

Changing a Signal Builder's Time Range

To change the time range, select Change Time Range from the Signal Builder's Axes menu. A dialog box appears.

Edit the Min time and Max time fields as necessary to reflect the beginning and ending times of the new time range, respectively. Click OK.

Exporting Signal Group Data

To export the data that define a Signal Builder block's signal groups to the MATLAB workspace, select Export to Workspace from the block's File menu. A dialog box appears.

The Signal Builder exports the data by default to a workspace variable named channels. To export to a differently named variable, enter the variable's name in the Variable name field. Click OK. The Signal Builder exports the data to the workspace as the value of the specified variable.

The exported data is an array of structures. The structure's xData and yData fields contain the coordinate points defining signals in the currently selected signal group. You can access the coordinate values defining signals associated with other signal groups from the structure's allXData and allYData fields.

Printing, Exporting, and Copying Waveforms

The Signal Builder dialog box allows you to print, export, and copy the waveforms visible in the active signal group.

To print the waveforms to a printer, select Print from the block's File menu.

You can also export the waveforms to other destinations by using the Export option from the block's File menu. From this submenu, select one of the following destinations:

To copy the waveforms to the system clipboard for pasting into other applications, select Copy Figure To Clipboard from the block's Edit menu.

Simulating with Signal Groups

You can use standard simulation commands to run models containing Signal Builder blocks or you can use the Signal Builder's Run all command (see Running All Signal Groups).

Activating a Signal Group

During a simulation, a Signal Builder block always outputs the active signal group. The active signal group is the group selected in the Signal Builder dialog box for that block, if the dialog box is open, otherwise the group that was selected when the dialog box was last closed. To activate a group, open the group's Signal Builder dialog box and select the group.

Running Different Signal Groups in Succession

The Signal Builder's toolbar includes the standard Simulink buttons for running a simulation. This facilitates running several different signal groups in succession. For example, you can open the dialog box, select a group, run a simulation, select another group, run a simulation, etc., all from the Signal Builder's dialog box.

Running All Signal Groups

To run all the signal groups defined by a Signal Builder block, open the block's dialog box and click the Run all button

from the Signal Builder's toolbar. The Run all command runs a series of simulations, one for each signal group defined by the block. If you installed Simulink Verification and Validation on your system and are using the Model Coverage Tool, the Run all command configures the tool to collect and save coverage data for each simulation in the MATLAB workspace and display a report of the combined coverage results at the end of the last simulation. This allows you to quickly determine how well a set of signal groups tests your model.

Simulation Options Dialog Box

The Simulation Options dialog box allows you to specify simulation options pertaining to the Signal Builder. To display the dialog box, select Simulation Options from the Signal Builder's File menu. The dialog box appears.

The dialog box allows you to specify the following options.

Signal values after final time

The setting of this control determines the output of the Signal Builder block if a simulation runs longer than the period defined by the block. The options are

Sample time

Determines whether the Signal Builder block outputs a continuous (the default) or a discrete signal. If you want the block to output a continuous signal, enter 0 in this field. For example, the following display shows the output of a Signal Builder block set to output a continuous Gaussian waveform over a period of 10 seconds.

If you want the block to output a discrete signal, enter the sample time of the signal in this field. The following example shows the output of a Signal Builder block set to emit a discrete Gaussian waveform having a 0.5 second sample time.

Enable zero crossing

Specifies whether the Signal Builder block detects zero-crossing events (enabled by default). For more information, see Zero-Crossing Detection.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS