Scope Viewer Tasks

Attach Scope Viewer to Signal

Using the Context Menu

  1. In a Simulink® block diagram, right-click a signal and select Create & Connect Viewer > Simulink > Scope.

    After you attach a Scope viewer, a viewer window opens, where simulation results appear after you simulate the model.

Using the Signal and Scope Manager

  1. In a Simulink block diagram, right-click a signal, and select Signal & Scope Manager.

  2. In the Signal & Scope dialog box, in the Types pane and under the Viewers node, expand a product node to show the available viewers.

      Note:   The Scope viewer displayed in the Signal and Scope Manager Types pane is not the same as a Simulink Scope block. For an explanation of the differences, see Scope Block and Scope Viewer Differences.

  3. Select a viewer, and then click Attach to model.

    The viewer is added to a table on the Viewers tab in the Generators/Viewers in model pane.

    The Input column identifies the viewer axis the signal is attached too.

Add Signal to an Existing Scope Viewer

  1. In a Simulink block diagram, right-click a signal.

  2. From the signal context menu, select Connect to viewer, and then select the name of a viewer you want to attach to the signal.

    A viewer symbol is added to the signal line.

You can also add signals to a signal viewer using the Signal and Scope Manager. See Signal and Scope Manager.

    Note:   If you add or remove signals from a Scope viewer, the title and legends update only when you close a viewer, run a simulation, and then reopen the viewer.

Display a Scope Viewer

  1. Right-click a Scope viewer symbol . From the context menu, select Open Viewer, and then a viewer name.

  2. Select the Parameters button . In the Viewer: Scope parameters dialog box, set parameters to better visualize the simulation results.

  3. Run a simulation. The Viewer: Scope window displays simulations results for the attached signals.

Save Simulation Data With Scope Viewer

Simulink can save simulation data to the MATLAB® workspace using a Simulink.SimulatationData.Dataset object. See Simulink.SimulationData.Dataset.

  1. Add a Scope viewer to your model. See Attach Scope Viewer to Signal.

  2. Add signals to the Scope viewer using the Signal Selector. From the toolbar, select the Signal Selector button , and then select check boxes for the signals.

  3. On the Viewer: Scope parameters dialog, From the toolbar, click the Parameters button .

  4. Click the History tab, and then select the Log/Unlog Viewed Signals to Workspace button. This selects the Log signal data parameter check box for the attached signals.

  5. From the Simulink editor menu, select Simulation > Model Configuration Parameters > Data Import/Export. In the right pane, select the Signal logging check box. From the Signal logging format list, select Dataset. Use the default object logsout or enter your own variable name. Click OK.

  6. Run a simulation. Simulink saves data to the MATLAB variable logsout.

  7. At the MATLAB command prompt, enter the commands to view the logged data from logsout, where x1 is the name of the signal.

    x1_data = logsout.get('x1').Values.Data
    x1_time = logsout.get('x1').Values.Time

Create Multiple Axes

You can add multiple plots (axes) to a Scope viewer. Each axes can have different y-axis settings.

  1. Add a Scope viewer to your model. See Attach Scope Viewer to Signal.

  2. Right-click a signal, and then select Signal & Scope Manager.

  3. In the Generators/Viewers in model group box, select a viewer tab.

  4. Click the Viewer button , and then on the viewer window toolbar, click the Parameters button . In the Number of axes box, enter 3, and then click OK.

  5. In the Signals connected to Generator/Viewer group box, select the first input.

  6. Click the Signal Selector button . In the Signal Selector dialog box, select the signal or signals to add to this axis, and then close the dialog.

  7. Add signals to the rest of the inputs.

  8. In the block diagram, double-click the viewer symbol over a signal to open the Scope viewer, and then run the simulation.

Was this topic helpful?