Open interactive digital signal processing tool
s = sptool('Signals')
f = sptool('Filters')
s = sptool('Spectra')
[s,ind] = sptool(___)
s = sptool(___,0)
struc = sptool('create',paramlist)
struc = sptool('load',paramlist)
SPTool will be removed in a future release.
sptool, opens SPTool, a suite of four tools: Signal Browser, Filter Design and
Analysis Tool, FVTool, and Spectrum Viewer. These tools provide access to many of the signal, filter, and spectral
analysis functions in the toolbox. When you type
sptool at the command line, the SPTool suite
Using SPTool, you can:
Analyze signals listed in the Signals list box with the Signal Browser.
Design or edit filters with the Filter Design and Analysis Tool (includes a Pole/Zero Editor).
Analyze filter responses for filters listed in the Filters list box with FVTool.
Apply filters in the Filters list box to signals in the Signals list box.
Create and analyze signal spectra with the Spectrum Viewer.
Print the Signal Browser, Filter Design and Analysis Tool, and Spectrum Viewer.
You can activate all four integrated signal processing tools from SPTool.
The Signal Browser, hereafter referred to as the scope, allows you to view, measure, and analyze the time-domain information of one or more signals. To activate the Signal Browser, press the View button under the Signals list box in SPTool.
See the following sections for more information on the Signal Browser:
Select more than one signal in the Signals list box to show multiple signals within the same display or on separate displays. By default, the signals appear as different-colored lines on the same display. The signals can have different dimensions, sample rates, and data types. Each signal can be either real or complex valued.
By default, Signal Browser has a white axes background and chooses line colors for each channel in a manner
similar to the MATLAB®
plot function. Signal Browser considers each of the real and imaginary components of the input
signals to be a channel, and assigns each channel a line color in the following order:
If there are more than 7 channels, the scope repeats this order to assign line colors to the remaining channels. For example, if you select 4 complex-valued input signals, the following legend appears in the display.
If all the input signals are real-valued, Signal Browser skips the line colors that would be associated with their imaginary components. For example, if you select 4 real-valued input signals, the following legend appears in the display.
To manually modify any line color, select View > Style to open the Style dialog box. Next to Properties for line, select the signal name whose color you want to change. Then, next to Line, click the line color button () and select any color from the palette. To change the axes background color, click the Axes background color button (), and select any color from the palette.
You can display multiple channels of data on different displays in the window. In the toolbar, select View > Layout, or select the Layout button ().
You can tile the window into multiple displays. For example, if there are three inputs to the tool, you can display the signals in three separate displays. The layout grid shows a 4 by 4 grid, but you can select up to 16 by 16 by clicking and dragging within the layout grid.
When you use the Layout option to tile the window into multiple displays, the display highlighted in blue is referred to as the active display. The dialog boxes reference the active display.
The Signal Browser uses the longest time length of all the input signals selected in the Signals list box for the time range. To communicate the array of times that corresponds to the current display, the scope uses the Minimum time-axis limit, Time units, and Maximum time-axis limit indicators on the scope window. The following figure highlights these aspects of the Signal Browser window.
Minimum time-axis limit — The Signal Browser sets the minimum time-axis limit to 0.
Maximum time-axis limit — The Signal Browser sets the maximum time-axis limit to the final time step of the longest input signal.
Time units — The units used to describe the time-axis. The
Signal Browser sets the time units using the value of the Time Units parameter on the
Main tab of the Visuals:Time Domain Options dialog box. By default, this parameter is set
Metric (based on Time Span) and displays in metric units such as microseconds,
milliseconds, minutes, days, etc. You can change the unit of measure to
always display the time-axis values in units of seconds. You can change it to
None to suppress the display of units of measure on the
time-axis. When you set this parameter to
None, then the Signal
Browser shows only the word
Time on the time-axis.
To hide both the word
Time and the values on the time-axis, set the
Show time-axis labels parameter to
None. To hide both the word
Time and the values on the time-axis in all displays except the bottom
ones in each column of displays, set this parameter to
Bottom Displays Only. This
behavior differs from that of the Simulink® Scope (Simulink) block, which always shows the values but never shows a label on the x-axis.
Signal Browser uses the names of the signals in the SPTool as the text displayed in the legends. If you change the name of any selected signal in the Signals list box, its corresponding legend entry in Signal Browser changes immediately. To change the name of any selected signal, from the SPTool menu select Edit > Name. Signal Browser automatically updates the legend to reflect the new signal name you entered. Similarly, if you modify any entry in a legend in Signal Browser, then SPTool updates the corresponding signal name in the Signals list box.
You can specify whether to display the Signal Browser in maximized axes mode. In this mode, the axes are expanded to fill the entire display. In each display, there is no space to show titles or axis labels. The minimum and maximum time-axis limits are located at the far-left and far-right edges of the display. The values at the axis tick marks appear as grid lines on top of the axes. The following figure highlights how three displays appear in maximized axes mode in the Signal Browser window.
To enable or disable this mode, in the Signal Browser menu, select View > Properties to bring up the Visuals:Time Domain Options dialog box. In the Main pane, you can set the Maximize axes parameter to one of the following options:
Auto — In this mode, the axes appear maximized in all displays only if
the Title and Y-Axis label parameters are empty for every
display. If you enter any value in any display for either of these parameters, the axes are not maximized.
On — In this mode, the axes appear maximized in all displays. Any
values entered into the Title and Y-Axis label parameters are
Off — In this mode, none of the axes appear maximized.
See the Visuals — Time Domain Options section for more information.
The Measurements panels are the five panels that appear at the right side of the Signal Browser. These panels are labeled Trace selection, Cursor measurements, Signal statistics, Bilevel measurements, and Peak finder.
The Visuals — Time Domain Properties dialog box controls the visual configuration settings of the Signal Browser display. From the menu, select View > Configuration Properties to open this dialog box.
The Main pane of the Visuals — Time Domain Properties dialog box appears as follows.
Specify the units used to describe the time-axis. The default setting is
Metric. You can select one of the following options.
Metric — In this mode, the Signal Browser converts the times on
the time-axis to some metric units such as milliseconds, microseconds, days, etc.
The Signal Browser chooses the appropriate metric units, based on the minimum
time-axis limit and the maximum time-axis limit of the
Seconds — In this mode, the Signal Browser always displays the
units on the time-axis as seconds.
None — In this mode, the Signal Browser displays no units on the
time-axis. The Signal Browser shows only the word
Time on the
Specify how to display the time units used to describe the time-axis. The default setting
All. You can select one of the following options.
All — In this mode, the time-axis labels appear
in all displays.
None — In this mode, the time-axis labels do
not appear in the displays.
Bottom Displays Only — In this mode, the
time-axis labels appear only in the bottom row of the displays.
Select to turn on time-axis label display.
Specify whether to display the Signal Browser in maximized axes mode. In this mode, each of the axes is
expanded to fit into the entire display. In each display, there is no space to show labels. Tick mark values
are shown on top of the plotted data. The default setting is
Auto. You can select
one of the following options:
Auto — In this mode, the axes appear maximized in all displays
only if the Title and Y-Axis label parameters are empty for
every display. If you enter any value in any display for either of these parameters, the axes are not
On — In this mode, the axes appear maximized in all displays. Any
values entered into the Title and Y-Axis label parameters
Off — In this mode, none of the axes appear maximized.
The Display pane of the Visuals — Time Domain Properties dialog box appears as follows.
Specify the active display as an integer to get and set relevant properties. The number of a display corresponds to its column-wise placement index. Set this property to control which display has its axes colors, line properties, marker properties, and visibility changed.
When you use the Layout option to tile the window into multiple displays, the display highlighted in blue is
referred to as the active display. The default setting is
Specify the active display title as text. By default, the active display has no title.
Select this check box to show the legend in the display. The channel legend displays a name for each channel of each input signal. When the legend appears, you can place it anywhere inside of the scope window. To turn off the legend, clear the Show legend check box.
You can edit the name of any channel in the legend by double-clicking the current name and entering a new channel name. By default, if the signal has multiple channels, the scope uses an index number to identify each channel of that signal. To change the appearance of any channel of any input signal in the scope window, from the scope menu, select View > Style. The legend lets you modify what signals are shown. To show only one signal, click the signal name. To toggle a signal on/off, right-click the signal name.
When you select this check box, a grid appears in the display of the scope figure. To hide the grid, clear this check box.
When you select this check box, the scope splits the display into a magnitude plot and a phase plot. By default, this check box is cleared. If the input signal has complex values, the scope plots the real and imaginary portions on the same axes. These real and imaginary portions appear as different-colored lines on the same axes. Selecting this check box and clicking the Apply or OK button changes the display. The magnitude of the input signal appears on the top axes and its phase, in degrees, appears on the bottom axes.
This feature is useful for complex-valued input signals. If the input is a real-valued signal, selecting this check box returns the absolute value of the signal for the magnitude. The phase is 0 degrees for nonnegative input and 180 degrees for negative input.
Specify the minimum value of the y-axis.
When you select the Plot signal(s) as magnitude and phase check box, the value of this property always applies to the magnitude plot on the top axes. The phase plot on the bottom axes is always limited to a minimum value of -180 degrees.
Specify the maximum value of the y-axis.
When you select the Plot signal(s) as magnitude and phase check box, the value of this property always applies to the magnitude plot on the top axes. The phase plot on the bottom axes is always limited to a maximum value of 180 degrees.
Specify the text for the scope to display to the left of the y-axis.
This property becomes invisible when you select the Plot signal(s) as magnitude and
phase check box. When you enable that property, the y-axis label always appears
Magnitude on the top axes and
Phase on the bottom axes.
In the Style dialog box, you can customize the style of displays. You can change the color of the figure containing the displays, the background and foreground colors of display axes, and properties of lines in a display. From the Signal Browser menu, select View > Style.
The Style dialog box allows you to modify the following properties of the Signal Browser:
Specify the color that you want to apply to the background of the Signal Browser. By default, the figure color is gray.
Specify the type of plot to use. The default setting is
Line. Valid values for
Plot type are:
Stairs — Displays input signal as a
stairstep graph. A stairstep graph is made up of only horizontal lines and
vertical lines. Each horizontal line represents the signal value for a discrete sample period and is
connected to two vertical lines. Each vertical line represents a change in values occurring at a
sample. This approach is equivalent to the MATLAB
stairs function. Stairstep graphs are useful for drawing
time history graphs of digitally sampled data.
Specify the active display as a number, where a display number corresponds to the index of the input signal.
The number of a display corresponds to its column-wise placement index. The default setting is
1. Set this parameter to control which display should have its axes colors, line
properties, marker properties, and visibility changed.
Specify the color that you want to apply to the background of the axes for the active display.
Specify whether or not to use the displayed color of the scope when copying.
When you select File > Copy to Clipboard, the software changes the color of the scope to be printer friendly (white background, visible lines). If you want to copy and paste the scope with the colors displayed, select this check box.
Specify the signal for which you want to modify the visibility, line properties, and marker properties.
Specify whether the selected signal on the active display should be visible. If you clear this check box, the line disappears.
Specify the line style, line width, and line color for the selected signal on the active display.
Specify marks for the selected signal on the active display to show at data points. This parameter is
similar to the
Marker property for the MATLAB Handle Graphics® plot objects.
The Filter Designer app allows you to design and edit FIR and IIR filters. To launch the app, press either the New button or the Edit button under the Filters list box in SPTool.
The Filter Designer app has a Pole/Zero Editor you can access by selecting the icon in the left column.
The Filter Visualization Tool (FVTool) allows you to view the characteristics of a designed or imported filter, including its magnitude response, phase response, group delay, phase delay, pole-zero plot, impulse response, and step response. To activate FVTool, click the View button under the Filters list box in SPTool.
The Spectrum Viewer allows you to analyze frequency-domain data graphically using a variety of methods of spectral density estimation, including the Burg method, the FFT method, the multitaper method, the MUSIC eigenvector method, Welch’s method, and the Yule-Walker autoregressive method. To activate the Spectrum Viewer:
Click the Create button under the Spectra list box to compute the power spectral density for a signal selected in the Signals list box in SPTool. You may need to click Apply to view the spectra.
Click the View button to analyze spectra selected under the Spectra list box in SPTool.
Click the Update button under the Spectra list box in SPTool to modify a selected power spectral density signal.
In addition, you can right-click in any plot display area to modify signal properties.
You can import or export data from SPTool using the command line.
The following commands export component structures from the currently open SPTool:
s = sptool('Signals') returns a structure array of all the signals.
f = sptool('Filters') returns a structure array of all the filters.
s = sptool('Spectra') returns a structure array of all the spectra.
[s,ind] = sptool(___) returns an index vector indicating which of the
s are currently selected in SPTool.
s = sptool(___,0) returns only the currently selected objects.
The following commands create component structures and load them into SPTool, opening SPTool if necessary:
struc = sptool('create',paramlist) creates in the workspace a component structure,
struc, defined by
struc into SPTool.
struc = sptool('load',paramlist) loads the component structure defined by
paramlist into SPTool. If you specify an output argument, then the command also creates
a component structure in the workspace.
Example: Create and load a 5th-order Butterworth filter with a cutoff frequency
of 0.5π rad/sample. Specify the filter in state-space representation, label it
Butterworth within SPTool, and set it to filter digital signals sampled at 1
[z,p,k] = butter(5,0.5); struc = sptool('create','Filter','zpk',z,p,k,1e3,'Butterworth'); sptool('load',struc)
Example: Load into SPTool the periodogram PSD estimate of a 512-sample
sinusoidal signal embedded in white noise. Work in normalized units and specify a sinusoid frequency of
π/4 rad/sample. Label the spectrum
n = 0:511; x = sin(pi/4*n)+randn(size(n))/10; [pxx,w] = periodogram(x); sptool('load','Spectrum',pxx,w,'PSD')
Example: Create and load a quadratic chirp modulated by a Gaussian. Specify a sample rate of 2 kHz and a signal duration of 2 seconds. Generate a copy of the structure in the workspace.
t = 0:1/2000:2-1/2000; q = chirp(t-2,4,1/2,6,'quadratic',100,'convex').*exp(-4*(t-1).^2); Chirp = sptool('load',q,2000)
Chirp = struct with fields: data: [4000×1 double] Fs: 2000 type: 'vector' lineinfo:  SPTIdentifier: [1×1 struct] label: 'sig'
The parameters in
paramlist must be input in the following order:
The parameters are defined as follows:
Specify as one of
Form or structure of a filter. Specify as one of
|Vector of doubles representing a signal or spectrum.|
Optional parameter that specifies the sample rate. If omitted,
Frequency vector. This parameter applies only if
Optional parameter that specifies the variable name of the
component within SPTool. If omitted,