generateScript
Generate MATLAB script to create scope with current settings
Syntax
Description
generateScript(
generates a MATLAB® script that can recreate a scope object with the current settings in the
scope. scope
)
Examples
Generate Script from spectrumAnalyzer
Create a
spectrumAnalyzer
object.scope = spectrumAnalyzer(); show(scope);
Set options in the Spectrum Analyzer. For this example, select both Spectrum and Spectrogram in the Scope 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 the Scope tab, or enter this command in the MATLAB command prompt.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 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]);
Generate Script from dsp.ArrayPlot
Create a
dsp.ArrayPlot
object.scope = dsp.ArrayPlot(); show(scope);
Set options in the Array Plot. For this example, from the Measurements tab, turn on the Data Cursors. From the Scope tab, turn on Legend. Click Settings. Select Magnitude 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 the Scope tab, or enter the following in the MATLAB command prompt:generateScript(scope);
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;
Generate Script from timescope
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 the Scope tab, or enter the following in the MATLAB command prompt:generateScript(scope);
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
— Scope object
scope object
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 R2019aR2024a: dsp.SpectrumAnalyzer
System object warns
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 of
dsp.SpectrumAnalyzer
with spectrumAnalyzer
.
This table shows how the generateScript
function typically uses the
dsp.SpectrumAnalyzer
System object and explains how to update existing code to use the
spectrumAnalyzer
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); |
R2022b: New support for dsp.DynamicFilterVisualizer
object
Starting in R2022b, the generateScript
function supports the
dsp.DynamicFilterVisualizer
object.
R2022a: Support for dsp.SpectrumAnalyzer
object will be removed
The generateScript
function will stop supporting the
dsp.SpectrumAnalyzer
object in a future release. Use the
spectrumAnalyzer
object instead.
See Also
spectrumAnalyzer
| dsp.ArrayPlot
| timescope
| dsp.DynamicFilterVisualizer
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)