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:
From the Simulation tab, click Library Browser .
From Simulink / Sinks, drag a copy of the Floating Scope block into your model.
To connect signals to your floating scope:
Double-click the Floating Scope block.
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.
Select the signals you want to connect to the scope. To select multiple signals, click and drag.
In the Connect pop-up, select the check box next to the signals you want to connect.
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.
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
Select a signal to view.
In the Simulation tab, in the Prepare gallery, select Add Viewer.
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.
Open the scope by double-clicking a Floating Scope block or Scope viewer icon .
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.
Select the signals you want to connect to the scope. To select multiple signals, click and drag.
In the Connect pop-up, select the check box next to the signals you want to connect.
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.
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);
From the Floating Scope window, select View > Configuration Properties.
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.
From the Simulink Editor, on the Modeling tab, click Model Settings.
In the Configuration Properties window, select Data Import/Export.
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.
To add viewers or generators, click and choose a viewer. New viewers and generators are not connected to any signals.
To connect signals, click a viewer or generator, and click .
To delete a viewer or generator, click .
Quickly Switch Visualization of Different Signals on a Floating Scope
Open a Floating Scope window.
On the toolbar, click the Lock button so that the icon is unlocked .
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.
After clicking on the canvas, the selected display removes connections to any previously selected signals.
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
Scope | Floating Scope | Scope Viewer