Main Content

generateScript

Generate MATLAB script to create scope with current settings

Description

generateScript(scope) generates a MATLAB® script that can recreate a scope object with the current settings in the scope.

Examples

Generate Script from dsp.SpectrumAnalyzer

You can change Spectrum Analyzer settings using menus and options in the interface of the scope, or by changing properties at the command line. If you change settings in the dsp.SpectrumAnalyzer interface, you can generate the corresponding command line settings to use later.

Note

The script only generates commands for settings that are available from the command line, applicable to the current visualization, and changed from the default value.

This example shows how to generate a script after making changes to the dsp.SpectrumAnalyzer in the interface:

  1. Create a dsp.SpectrumAnalyzer System object.

    scope = dsp.SpectrumAnalyzer();
    show(scope);
  2. Set options in the Spectrum Analyzer. For this example, turn on the Cursor Measurements. Also in the Spectrum Settings, change the View type to Spectrum and spectrogram and set the Axes Layout to Horizontal.

  3. Generate a script to recreate the dsp.SpectrumAnalyzer with the same modified settings. Either select File > Generate MATLAB Script or enter:

    generateScript(scope);

    A new editor window opens with code to regenerate the same scope.

    % Creation Code for 'dsp.SpectrumAnalyzer'.
    % Generated by Spectrum Analyzer on 10-Mar-2019 16:25:49 -0500.
    
    specScope = dsp.SpectrumAnalyzer('ViewType','Spectrum and spectrogram', ...
        'AxesLayout','Horizontal');
    % Cursor Measurements Configuration
    specScope.CursorMeasurements.Enable = true;

Generate Script from dsp.ArrayPlot

This example shows how to generate a script after making changes to the dsp.ArrayPlot in the interface.

Note

The script only generates commands for settings that are available from the command line, applicable to the current visualization, and changed from the default value.

  1. Create a dsp.ArrayPlot object.

    scope = dsp.ArrayPlot();
    show(scope);
  2. Set options in the Array Plot. For this example, from the Measurements tab, turn on the Data Cursors. From the Plot tab, turn on Legend and Magnitude and Phase. Click Settings and give the plot an XLabel and Title.

  3. Generate a script to recreate the dsp.ArrayPlot with the same modified settings. Either select Generate Script from the Plot tab, or enter:

    generateScript(scope);

    A new editor window opens with code to regenerate the same scope.

    % Creation Code for 'dsp.ArrayPlot'.
    % Generated by Array Plot on 20-Sep-2019 14:27:45 -0400.
    
    arrayPlot = dsp.ArrayPlot('Title','My Array Plot', ...
        'XLabel','Frequency', ...
        'PlotAsMagnitudePhase',true, ...
        'ShowLegend',true, ...
        'Position',[2075 330 774 502]);

Generate Script from timescope

Generate MATLAB script after making changes to the timescope object in the scope window.

Note

The script only generates commands for settings that are available from the command line, applicable to the current visualization, and changed from the default value.

  1. Create a timescope object.

    scope = timescope;
    show(scope)
  2. Set options in the Time Scope. For this example, on the Scope tab, click Settings. Under Display and Labels, select Show Legend and Magnitude Phase Plot. Set the Title as well.

  3. Generate a script to recreate the timescope with the same modified settings. Either select Generate Script from the Scope tab, or enter:

    generateScript(scope);

    A new editor window opens with code to regenerate the same scope.

    % Creation Code for 'timescope'.
    % Generated by Time Scope on 8-Nov-2020 13:51:54 -0500.
    
    timeScope = timescope('Position',[2286 355 800 500], ...
        'Title','My Time Scope', ...
        'ShowLegend',true, ...
        'PlotAsMagnitudePhase',true);

Input Arguments

collapse all

Object whose settings you want to recreate with a script.

Introduced in R2019a