Main Content

Floating Scope and Scope Viewer Tasks

These tasks walk through frequently used Floating Scope and Scope Viewer procedures.

Add Floating Scope Block to Model and Connect Signals

To add a Floating Scope block from the Simulink® block library:

  1. From the Simulation tab, click Library Browser .

  2. From Simulink / Sinks, drag a copy of the Floating Scope block into your model.

To connect signals to your floating scope:

  1. Double-click the Floating Scope block.

  2. In the scope window toolbar, click the signal selection button . You may need to select the dropdown next to the lock button to see signal selection.

    The Simulink Editor canvas grays, indicating you can interactively select signals to connect to the scope.

  3. Select the signals you want to connect to the scope. To select multiple signals, click and drag.

  4. In the Connect pop-up, select the check box next to the signals you want to connect.

    vdp model in connection mode connecting the scope to the x1 and x2 signals

  5. For scopes with multiple displays (subplots), select the desired display from the drop-down at the top of the Connect pop-up and connect the signals.

  6. Click the X in the upper-right of the Simulink canvas.

    Your signals are now connected to the floating scope. Run a simulation to see the plotted signals.

Add Scope Viewer to a Signal

  1. Select a signal to view.

  2. In the Simulation tab, in the Prepare gallery, select Add Viewer.

  3. From the Add Viewer window, select a viewer, for example Scope.

Add Signals to an Existing Floating Scope or Scope Viewer

Connect signals to an existing Floating Scope or Scope viewer.

  1. Open the scope by double-clicking a Floating Scope block or Scope viewer icon .

  2. In the scope window toolbar, click the signal selection button . You may need to select the drop-down next to the lock button to see signal selection.

    The Simulink Editor canvas grays, indicating you can interactively select signals to connect to the scope.

  3. Select the signals you want to connect to the scope. To select multiple signals, click and drag.

  4. In the Connect pop-up, select the check box next to the signals you want to connect.

    vdp model in connection mode connecting the scope to the x1 and x2 signals

  5. For scopes with multiple displays (subplots), select the desired display from the drop-down at the top of the Connect pop-up and connect the signals.

  6. Click the X in the upper-right of the Simulink canvas.

    Your signals are now connected to the scope. Run a simulation to see the plotted signals.

Save Simulation Data from Floating Scope

This example shows how to save signals to the MATLAB® Workspace using a Floating Scope block. You can follow the same procedure to save data from a Scope Viewer. To save data from a Scope or Time Scope block, see Save Simulation Data Using Scope Block.

This example uses a modified version of the vdp model. In this example, a floating scope is connected to the x1 and x2 signals.

Set Up Signal Logging from the Floating Scope

model = 'vdpFloatingScope';
open_system(model);

  1. From the Floating Scope window, select View > Configuration Properties.

  2. On the Logging tab, select Log/Unlog Viewer Signals to Workspace. When you click this button, Simulink places logging symbols on the signals connected to the Floating Scope.

  3. From the Simulink Editor, on the Modeling tab, click Model Settings.

  4. In the Configuration Properties window, select Data Import/Export.

  5. Select the Signal logging check box. You can also set the parameter name from this window. The default parameter name is logsout.

Use Saved Simulation Data

Run a simulation. Simulink saves data to the MATLAB Workspace in a variable out.

out = sim(model);

Simulink saves all logged or saved simulation data as one structure. In out, the scope data object logsout has one element for each logged signal.

In the MATLAB Command Window, plot the log data for x1.

x1_data = out.logsout.get('x1').Values.Data;
x1_time = out.logsout.get('x2').Values.Time;
plot(x1_time,x1_data);

Add and Manage Viewers

Open the Viewers and Generators Manager. From the Simulink toolstrip Simulation tab, expand the Prepare gallery and select Viewers Manager.

You can see any viewers or generators you added in the Viewers and Generators Manager.

Viewers and Generators Manager pane

  • To add viewers or generators, click Plus sign button and choose a viewer. New viewers and generators are not connected to any signals.

  • To connect signals, click a viewer or generator, and click Signal selection button.

  • To delete a viewer or generator, click Delete trash can button.

Quickly Switch Visualization of Different Signals on a Floating Scope

  1. Open a Floating Scope window.

  2. On the toolbar, click the Lock button so that the icon is unlocked .

  3. In the model, click a signal line to select and highlight the signal line. To select multiple signals, hold down the Shift key while selecting signals.

    Highlighted signal line in a Simulink canvas

    After clicking on the canvas, the selected display removes connections to any previously selected signals.

  4. Run a simulation. As long as the unlock icon is showing, you can click between signals to switch which signal appears in the Floating Scope.

See Also

| |

Related Topics