generateScript - Generate MATLAB script to create scope with current settings - MATLAB (original) (raw)
Generate MATLAB script to create scope with current settings
Syntax
Description
generateScript([scope](#mw%5Fcbf4a65b-7a61-49f7-beab-b4508fea96fb))
generates a MATLAB® script that can recreate a scope object with the current settings in the scope.
Examples
Create a
spectrumAnalyzer
object.
scope = spectrumAnalyzer();
show(scope);Set options in the Spectrum Analyzer. For this example, select bothSpectrum and Spectrogram in theScope tab of the Spectrum Analyzer toolstrip.
In addition, enable Max-Hold Trace and Min-Hold Trace in the Spectrum tab.Generate a script to recreate the
spectrumAnalyzer
with the modified settings. Either click Generate Script from theScope tab, or enter this command in the MATLAB command prompt.
A new editor window opens with code to regenerate the same scope.
% Generated by MATLAB(R) 9.12 (R2022a) and DSP System Toolbox 9.14 (R2022a).
% Generated on 15-Nov-2021 15:24:16 -0500.
% Construct a spectrumAnalyzer object
specScope = spectrumAnalyzer(ViewType="spectrum-and-spectrogram", ...
PlotMaxHoldTrace=true, ...
PlotMinHoldTrace=true, ...
Position=[184 190 742 563]);Create a
dsp.ArrayPlot
object.
scope = dsp.ArrayPlot();
show(scope);Set options in the Array Plot. For this example, from theMeasurements tab, turn on the Data Cursors. From the Scope tab, turn onLegend. Click Settings. SelectMagnitude Phase Plot, and specify an _x_-axis label and a title.
Generate a script to recreate the
dsp.ArrayPlot
with the same modified settings. Either select Generate Script from theScope tab, or enter the following in the MATLAB command prompt:
A new editor window opens with code to regenerate the same scope.
% Generated by MATLAB(R) 24.2 (R2024b) and DSP System Toolbox 24.2 (R2024b).
% Generated on 24-Apr-2024 14:37:28 -0400.
% Construct a dsp.ArrayPlot object
arrayPlot=dsp.ArrayPlot(AxesScaling="Manual", ...
Position=[2260 393 800 500], ...
PlotAsMagnitudePhase=true, ...
Title="My Array Plot", ...
XLabel="Frequency", ...
ShowLegend=true);
% Cursor Measurements Configuration
arrayPlot.CursorMeasurements.Enabled=true;Create a
timescope
object.
scope = timescope;
show(scope)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.
Generate a script to recreate the
timescope
with the same modified settings. Either select Generate Script from theScope tab, or enter the following in the MATLAB command prompt:
A new editor window opens with code to regenerate the same scope.
% Generated by MATLAB(R) 24.2 (R2024b) and DSP System Toolbox 24.2 (R2024b).
% Generated on 24-Apr-2024 14:30:00 -0400.
% Construct a timescope object
timeScope=timescope(AxesScaling="manual", ...
Position=[2546 147 800 500], ...
PlotAsMagnitudePhase=true, ...
Title="My Time Scope", ...
ShowLegend=true);
Input Arguments
Scope object whose settings you want to recreate with a script, specified as one of the following:
spectrumAnalyzer
objectdsp.ArrayPlot
objecttimescope
objectdsp.DynamicFilterVisualizer
object
Version History
Introduced in R2019a
The dsp.SpectrumAnalyzer
System object™ warns in R2024a. Use the spectrumAnalyzer object instead.
Update Code
No updates to your code are required except replacing instances ofdsp.SpectrumAnalyzer
with spectrumAnalyzer
.
This table shows how the generateScript
function typically uses thedsp.SpectrumAnalyzer
System object and explains how to update existing code to use thespectrumAnalyzer
object.
Discouraged Usage | Recommended Replacement |
---|---|
scope = dsp.SpectrumAnalyzer; show(scope) Make changes in the UI. Generate script.generateScript(scope); A new editor window opens with code to regenerate the same scope.% Creation Code for 'dsp.SpectrumAnalyzer'. % Generated by Spectrum Analyzer on 16-Nov-2021 11:35:13 -0500. specScope = dsp.SpectrumAnalyzer('ViewType','Spectrum and spectrogram', ... 'PlotMaxHoldTrace',true, ... 'PlotMinHoldTrace',true); | scope = spectrumAnalyzer; show(scope) Make changes in the UI. Generate script.generateScript(scope); A new editor window opens with code to regenerate the same scope.% Generated by MATLAB(R) 9.12 (R2022a) and DSP System Toolbox 9.14 (R2022a). % Generated on 16-Nov-2021 11:36:19 -0500. % Construct a spectrumAnalyzer object specScope = spectrumAnalyzer(ViewType="spectrum-and-spectrogram", ... PlotMaxHoldTrace=true, ... PlotMinHoldTrace=true); |
Starting in R2022b, the generateScript
function supports thedsp.DynamicFilterVisualizer
object.
The generateScript
function will stop supporting thedsp.SpectrumAnalyzer
object in a future release. Use thespectrumAnalyzer
object instead.