dsp.DynamicFilterVisualizer
Display time-varying magnitude and phase response of digital filters
Description
The dsp.DynamicFilterVisualizer
object displays the magnitude
response and phase response of time-varying digital filters or time-varying filter
coefficients. The input to this object can be a filter coefficients vector or a filter
System object™.
Using the dynamic filter visualizer, you can configure the plot settings, find the peak values, enable cursor measurements, and even generate script to recreate the plot with the current settings from the visualizer interface. For details, see Configure Dynamic Filter Visualizer.
Creation
Syntax
Description
returns a
dynamic filter visualizer object, dfv
= dsp.DynamicFilterVisualizerdfv
, that displays the magnitude
response of digital filters or filter coefficients.
returns a dynamic filter visualizer with the dfv
= dsp.DynamicFilterVisualizer(nfft
)FFTLength
property set
to nfft
.
returns a dynamic filter visualizer with the dfv
= dsp.DynamicFilterVisualizer(nfft
,Fs
)FFTLength
property set
to nfft
and the SampleRate
property set to
Fs
.
returns a dynamic filter visualizer with the dfv
= dsp.DynamicFilterVisualizer(nfft
,Fs
,range
)FFTLength
property set
to nfft
, the SampleRate
property set to
Fs
, and the FrequencyRange
property set to
range
.
returns a dynamic filter visualizer with each specified property set to the specified
value. You can specify name-value pair arguments in any order.dfv
= dsp.DynamicFilterVisualizer(Name=Value
)
Properties
Frequently Used
FFTLength
— FFT length
2048
(default) | positive integer
FFT length that the dynamic filter visualizer uses to compute spectral estimates, specified as a positive integer.
Tunable: Yes
Scope Window Use
In the Configuration section on the Plot tab of the Dynamic Filter Visualizer toolstrip, click Settings. In the Filter Visualizer Settings window that opens, under Data and Axes, set FFT Length to a positive integer.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
SampleRate
— Sampling rate of input
44100
(default) | positive scalar
Sampling rate of the input signal, specified as a real positive scalar in Hz.
Tunable: Yes
Scope Window Use
In the Configuration section on the Plot tab of the Dynamic Filter Visualizer toolstrip, click Settings. In the Filter Visualizer Settings window that opens, under Data and Axes, set Sample Rate (Hz) to a positive scalar.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
FrequencyRange
— Range of frequency axis
[0
22050
] (default) | two-element numeric vector
Range of the frequency axis, specified as a two-element numeric vector that is
monotonically increasing and of the form [fmin,
fmax]. The upper limit must be less than or equal to
Fs/2, where Fs is the value specified in
SampleRate
.
Tunable: Yes
Scope Window Use
In the Configuration section on the Plot tab of the Dynamic Filter Visualizer toolstrip, click Settings. In the Filter Visualizer Settings window that opens, under Data and Axes, set Frequency Range to a two-element numeric vector.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
XScale
— x-axis scale
'Log'
(default) | 'Linear'
X-axis scale, specified as either 'Linear'
or
'Log'
.
Tunable: Yes
Scope Window Use
In the Configuration section on the
Plot tab of the Dynamic Filter Visualizer toolstrip, click
Settings. In the Filter Visualizer Settings window that
opens, under Data and Axes, set X-Scale to
Linear
or Log
.
MagnitudeDisplay
— y-axis units
'Magnitude (dB)'
(default) | 'Magnitude'
|'Magnitude squared'
Y-axis units, specified as one of the following:
'Magnitude'
'Magnitude (dB)'
'Magnitude squared'
Tunable: Yes
Scope Window Use
In the Configuration section on the
Plot tab of the Dynamic Filter Visualizer toolstrip, click
Settings. In the Filter Visualizer Settings window that
opens, under Data and Axes, set Display
Unit to Magnitude
, Magnitude
(dB)
, or Magnitude Squared
.
PlotAsMagnitudePhase
— Plot magnitude and phase response of filter
false
(default) | true
true
– The filter visualizer plots the magnitude and phase responses of the filter on two separate axes.false
– The filter visualizer plots only the magnitude response of the filter.
Tunable: Yes
Scope Window Use
In the Configuration section on the Plot tab of the Dynamic Filter Visualizer toolstrip, click the Magnitude Phase button.
PlotType
— Option to control type of plot
"Line"
(default) | "Stairs"
| "Stem"
Specify the type of plot to use in the filter visualizer window as one of these:
"Line"
– The filter visualizer connects each point on the magnitude and phase response plot with a line."Stairs"
– The filter visualizer displays the filter response (magnitude, phase, or both) as a stair-step graph. A stair-step graph is made up of only horizontal lines and vertical lines. Each horizontal line represents the filter response over a frequency value and is connected to two vertical lines. Each vertical line represents a change in values occurring at a frequency."Stem"
– The filter visualizer displays the frequency response as circles with vertical lines extending down to the x-axis at each of the frequency values.
Tunable: Yes
Scope Window Use
In the Configuration section on the
Plot tab of the Dynamic Filter Visualizer toolstrip, click
Settings. In the Filter Visualizer Settings window that
opens, under Data and Axes, set Plot Type
to Line
, Stairs
, or
Stem
.
AxesScaling
— Axes scaling mode
"OnceAtStop"
(default) | "Auto"
| "Manual"
| "Updates"
Specify the scaling mode for the axes as one of these:
"Auto"
— The filter visualizer scales the axes as needed to fit the data, both during and after simulation."Manual"
— The filter visualizer does not scale the axes automatically."OnceAtStop"
— The filter visualizer scales the axes when the simulation stops."Updates"
— The filter visualizer scales the axes limits once after a set number of visual updates. The number of updates is determined by the value of theAxesScalingNumUpdates
property.
Tunable: Yes
Scope Window Use
Hover over the filter visualizer to see the maximize , pan
, zoom
, and autoscale
buttons. You can also zoom and pan using your
mouse.
Data Types: char
| string
AxesScalingNumUpdates
— Number of updates before scaling
100 (default) | real positive integer
Specify the number of updates before scaling as a real, positive scalar integer.
Tunable: Yes
Dependency
To enable this property, set AxesScaling
to
"Updates"
.
Data Types: double
Measurements
MeasurementChannel
— Channel for which to obtain measurements
1
(default) | positive integer
Channel for which to obtain measurements, specified as a positive integer in the range [1 N], where N is the number of input channels.
Tunable: Yes
Scope Window Use
Click the Measurements tab on the Dynamic Filter Visualizer toolstrip. In the Channel section, select a Channel.
Data Types: double
CursorMeasurements
— Cursor measurements
CursorMeasurementsConfiguration
object
Cursor measurements to display waveform cursors, specified as a CursorMeasurementsConfiguration
object.
All CursorMeasurementsConfiguration
properties are
tunable.
Tunable: Yes
Scope Window Use
Click the Measurements tab on the Dynamic Filter Visualizer toolstrip and modify the cursor measurements in the Cursors section.
PeakFinder
— Peak finder measurements
PeakFinderConfiguration
object
Peak finder measurements to compute and display the largest calculated peak
values, specified as a PeakFinderConfiguration
object.
All PeakFinderConfiguration
properties are tunable.
Tunable: Yes
Scope Window Use
Click the Measurements tab on the Dynamic Filter Visualizer toolstrip and modify the peak finder measurements in the Peaks section.
Visualization
Name
— Caption to display on Dynamic Filter Visualizer window
'Dynamic Filter Visualizer'
(default) | character vector | string scalar
Caption to display on the Dynamic Filter Visualizer window, specified as a character vector or a string scalar.
Example: 'Dynamic Filter Visualizer'
Example: "Dynamic Filter Visualizer"
Tunable: Yes
Position
— Scope window position in pixels
[left bottom 800 500]
(default) | four-element double vector
Scope window position in pixels, specified as a four-element double vector of the
form [left bottom width height]. The default value of this property is dependent on
the screen resolution, and is such that the window is positioned in the center of the
screen, with a width and height of 800
and 500
pixels, respectively.
Tunable: Yes
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
MaximizeAxes
— Maximize axes control
"Auto"
(default) | "On"
| "Off"
Specify whether to display the filter visualizer in maximized-axes mode. In this mode, the axes are expanded to fit into the entire display. To conserve space, labels do not appear in each display. Instead, tick-mark values appear on top of the plotted data. You can select one of the following options:
"Auto"
— The axes appear maximized in all displays only if theTitle
andYLabel
properties are empty for every display. If you enter any value in any display for either of these properties, the axes are not maximized."On"
— The axes appear maximized in all displays. Any values entered into theTitle
andYLabel
properties are hidden."Off"
— None of the axes appear maximized.
Tunable: Yes
Scope Window Use
Hover over the Dynamic Filter Visualizer window to see the maximize axes button
.
Data Types: char
| string
Title
— Display title
''
(default) | character vector | string scalar
Display title, specified as a character vector or a string scalar.
Example: 'Magnitude Response'
Example: "Magnitude Response"
Tunable: Yes
Scope Window Use
In the Configuration section on the Plot tab of the Dynamic Filter Visualizer toolstrip, click Settings. In the Filter Visualizer Settings window that opens, under Display and Labels, set Title to a character vector or a string scalar.
YLimits
— y-axis limits
[-25
25
] (default) | two-element row vector
Y-axis limits, specified as a two-element numeric row vector with the second element greater than the first element and of the form [ymin, ymax].
Tunable: Yes
Scope Window Use
In the Configuration section on the Plot tab of the Dynamic Filter Visualizer toolstrip, click Settings. In the Filter Visualizer Settings window that opens, under Data and Axes, set Y-Axis Limits to a two-element numeric vector.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
ShowLegend
— Show or hide legend
false
(default) | true
When this property is set to false
, no legend is displayed.
When this property is set to true
, a legend with automatic string
labels for each input filter is displayed.
Tunable: Yes
Scope Window Use
In the Configuration section on the Plot tab of the Dynamic Filter Visualizer toolstrip, click Legend.
Data Types: logical
FilterNames
— Names for input filters
{''}
(default) | cell array of character vectors | array of strings
Names to label the input filters in the legend, specified as a cell array of
character vectors or an array of strings. The default is an empty cell array. When
this property is set to an empty cell array, the filters are named by default names,
such as Filter 1
, Filter 2
, and so on.
Tunable: Yes
Scope Window Use
In the Configuration section on the Plot tab of the Dynamic Filter Visualizer toolstrip, click Legend. In the legend that appears on the plot, click the filter name.
ShowGrid
— Display grid
true
(default) | false
Set this property to true
to show grid lines on the
plot.
Scope Window Use
In the Configuration section on the Plot tab of the Dynamic Filter Visualizer toolstrip, click Settings. In the Filter Visualizer Settings window that opens, under Data and Axes, select Grid.
UpperMask
— Upper limit mask
Inf
(default) | two-column matrix
Upper limit spectral mask, specified as a two-column matrix. The first column represents the frequency values (Hz), and the second column represents the magnitude spectrum of the upper limit mask.
Tunable: Yes
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
LowerMask
— Lower limit mask
-Inf
(default) | two-column matrix
Lower limit spectral mask, specified as a two-column matrix. The first column represents the frequency values (Hz), and the second column represents the magnitude spectrum of the lower limit mask.
Tunable: Yes
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Usage
Description
dfv(
displays the time-varying
magnitude response of the object filter, filt
)filt
, in the Dynamic Filter
Visualizer figure, as long as filt
has a valid
freqz()
implementation.
Input Arguments
filt
— Input filter
filter System object
Input filter System object with a valid freqz()
implementation.
B
— Numerator polynomial coefficients
row vector
Numerator polynomial coefficients, specified as a row vector.
Data Types: single
| double
A
— Denominator polynomial coefficients
scalar | row vector
Denominator polynomial coefficients, specified as a:
scalar –– The filter is an FIR filter.
row vector –– The filter is an IIR filter.
Data Types: single
| double
Object Functions
Specific to dsp.DynamicFilterVisualizer
step | Display time-varying magnitude response |
Specific to Scopes
show | Display scope window |
hide | Hide scope window |
isVisible | Determine visibility of scope |
generateScript | Generate MATLAB script to create scope with current settings |
Examples
Plot Time-Varying Magnitude and Phase Response of FIR Filter
Design an FIR filter with time-varying magnitude and phase response. Plot this varying response on a dynamic filter visualizer.
Create a dsp.DynamicFilterVisualizer
object. Set the PlotAsMagnitudePhase
property to true
.
dfv = dsp.DynamicFilterVisualizer(PlotAsMagnitudePhase=1,... Title='Magnitude and Phase Response',... FilterNames=["FIR Filter","FIR Filter"])
dfv = dsp.DynamicFilterVisualizer with properties: FFTLength: 2048 SampleRate: 44100 FrequencyRange: [0 22050] XScale: 'Linear' MagnitudeDisplay: 'Magnitude (dB)' PlotAsMagnitudePhase: 1 PlotType: 'Line' AxesScaling: 'Auto' Show all properties
Vary the cutoff frequency of the FIR filter, k, from 0.1
to 0.5
in increments of 0.001
. View the varying magnitude and phase response using the dynamic filter visualizer.
for k = 0.1:0.001:0.5 b = fir1(90,k); dfv(b,1); end
Plot Time-Varying Magnitude Response of Variable Bandwidth FIR Filter
Visualize the varying magnitude response of the variable bandwidth FIR filter using the dynamic filter visualizer.
Create a dsp.DynamicFilterVisualizer
object.
dfv = dsp.DynamicFilterVisualizer(YLimits=[-160 10],... FilterNames="Variable Bandwidth FIR Filter")
dfv = dsp.DynamicFilterVisualizer with properties: FFTLength: 2048 SampleRate: 44100 FrequencyRange: [0 22050] XScale: 'Linear' MagnitudeDisplay: 'Magnitude (dB)' PlotAsMagnitudePhase: 0 PlotType: 'Line' AxesScaling: 'Manual' Show all properties
Design a bandpass variable bandwidth FIR filter with a center frequency of 5 kHz and a bandwidth of 4 kHz.
Fs = 44100; vbw = dsp.VariableBandwidthFIRFilter(FilterType='Bandpass',... FilterOrder=100,... SampleRate=Fs,... CenterFrequency=5e3,... Bandwidth=4e3);
Vary the center frequency of the filter. Visualize the varying magnitude response of the filter using the dsp.DynamicFilterVisualizer
object.
for idx = 1:100 dfv(vbw); vbw.CenterFrequency = vbw.CenterFrequency + 20; end
Version History
Introduced in R2018bR2022b: Filter names support array of strings
Starting in R2022b, you can specify the FilterNames
property of the
dsp.DynamicFilterVisualizer
object as an array of strings.
dfv = dsp.DynamicFilterVisualizer(FilterNames=["Filter 1", "Filter 2"]);
R2022b: Enhancements to the dsp.DynamicFilterVisualizer
object and the Dynamic Filter Visualizer UI
The dsp.DynamicFilterVisualizer
object has the following new properties starting
R2022b:
PlotAsMagnitudePhase
–– Split the magnitude and phase of the input signal and plot them on two separate axes within the same windowPlotType
–– Plot typeAxesScaling
–– Axes scaling modeAxesScalingNumUpdates
–– Number of updates before scalingMaximizeAxes
–– Maximize axes controlShowGrid
–– Grid visibility
The Dynamic Filter Visualizer app that you launch using the object has these enhancements in R2022b:
Magnitude Phase button –– This button corresponds to the
PlotAsMagnitudePhase
property in the object.Generate Script button –– Generate a script to re-create your dynamic filter visualizer plot with the same settings. When you click this button, an editor window opens with the code that you can use to re-create your
dsp.DynamicFilterVisualizer
object.
R2022b: Configure dsp.DynamicFilterVisualizer
measurements programmatically
You can now configure the cursor and the peak finder measurements in the dsp.DynamicFilterVisualizer
object programmatically using these properties:
MeasurementChannel
CursorMeasurements
PeakFinder
Apri esempio
Si dispone di una versione modificata di questo esempio. Desideri aprire questo esempio con le tue modifiche?
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
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)