Filter Visualization Tool
Filter Visualization Tool is an interactive tool that enables you to display the magnitude, phase response, group delay, impulse response, step response, pole-zero plot, and coefficients of a filter. You can export the displayed response to a file with File > Export.
FVTool can be opened programmatically using one of the methods described in Programmatic Use.
Display the magnitude response of a 6th-order elliptic filter. Specify a passband ripple of 3 dB, a stopband attenuation of 50 dB, a sample rate of 1 kHz, and a normalized passband edge of 300 Hz. Start FVTool from the command line.
[b,a] = ellip(6,3,50,300/500); fvtool(b,a)
Display and analyze multiple FIR filters, starting FVTool from the command line.
b1 = firpm(20,[0 0.4 0.5 1],[1 1 0 0]); b2 = firpm(40,[0 0.4 0.5 1],[1 1 0 0]); fvtool(b1,1,b2,1)
Display the associated analysis parameters by selecting Analysis > Analysis Parameters.
.
Start FVTool from the command line. Display the magnitude response of a 6th-order elliptic filter. Specify a passband ripple of 3 dB, a stopband attenuation of 50 dB, a sample rate of 1 kHz, and a normalized passband edge of 300 Hz.
[b,a] = ellip(6,3,50,300/500); h = fvtool(b,a)
h = Figure (filtervisualizationtool) with properties: Number: 1 Name: 'Filter Visualization Tool - Magnitude Response (dB)' Color: [0.9400 0.9400 0.9400] Position: [358 291 560 420] Units: 'pixels' Use get to show all properties
Display the phase response of the filter.
h.Analysis = 'phase'
h = Figure (filtervisualizationtool) with properties: Number: 1 Name: 'Filter Visualization Tool - Phase Response' Color: [0.9400 0.9400 0.9400] Position: [358 291 560 420] Units: 'pixels' Use get to show all properties
Turn on the plot legend and add text.
legend(h,'Phase plot')
Specify a sample rate of 1 kHz. Display the two-sided centered response.
h.Fs = 1000;
h.FrequencyRange='[-Fs/2, Fs/2)'
h = Figure (filtervisualizationtool) with properties: Number: 1 Name: 'Filter Visualization Tool - Phase Response' Color: [0.9400 0.9400 0.9400] Position: [358 291 560 420] Units: 'pixels' Use get to show all properties
View the all the properties of the plot. The properties specific to FVTool are at the end of the list.
get(h)
Grid: on Legend: 'on' AnalysisToolbar: 'on' FigureToolbar: 'on' DesignMask: 'off' SOSViewSettings: [1x1 dspopts.sosview] Fs: 1000 Alphamap: [1x64 double] CloseRequestFcn: 'closereq' Color: [0.9400 0.9400 0.9400] Colormap: [256x3 double] ContextMenu: [0x0 GraphicsPlaceholder] CurrentAxes: [1x1 Axes] CurrentCharacter: '' CurrentObject: [0x0 GraphicsPlaceholder] CurrentPoint: [0 0] DockControls: on FileName: '' IntegerHandle: on InvertHardcopy: on KeyPressFcn: '' KeyReleaseFcn: '' MenuBar: 'none' Name: 'Filter Visualization Tool - Phase Response' NextPlot: 'new' NumberTitle: on PaperUnits: 'inches' PaperOrientation: 'portrait' PaperPosition: [0.5167 2.7000 7.4667 5.6000] PaperPositionMode: 'auto' PaperSize: [8.5000 11] PaperType: 'usletter' Pointer: 'arrow' PointerShapeCData: [16x16 double] PointerShapeHotSpot: [1 1] Position: [358 291 560 420] Renderer: 'opengl' RendererMode: 'auto' Resize: on ResizeFcn: '' SelectionType: 'normal' ToolBar: 'auto' Type: 'figure' Units: 'pixels' WindowButtonDownFcn: '' WindowButtonMotionFcn: '' WindowButtonUpFcn: '' WindowKeyPressFcn: '' WindowKeyReleaseFcn: '' WindowScrollWheelFcn: '' WindowStyle: 'normal' BeingDeleted: off ButtonDownFcn: '' Children: [15x1 Graphics] Clipping: on CreateFcn: '' DeleteFcn: '' BusyAction: 'queue' HandleVisibility: 'on' HitTest: on Interruptible: on Parent: [1x1 Root] Selected: off SelectionHighlight: on Tag: 'filtervisualizationtool' UserData: [] Visible: on PhaseUnits: 'Radians' PolyphaseView: 'off' PhaseDisplay: 'Phase' Analysis: 'phase' OverlayedAnalysis: '' ShowReference: 'on' FrequencyScale: 'Linear' NormalizedFrequency: 'off' NumberofPoints: 8192 FrequencyVector: [1x256 double] FrequencyRange: '[-Fs/2, Fs/2)'
Design a 50th-order bandpass FIR filter with stopband frequencies 150 Hz and 350 Hz and passband frequencies 200 Hz and 300 Hz. The sample rate is 1000 Hz. Visualize the magnitude and phase response of the filter.
N = 50; Fstop1 = 150; Fstop2 = 350; Fpass1 = 200; Fpass2 = 300; Fs = 1e3; bpFilt = designfilt('bandpassfir','FilterOrder',N, ... 'StopbandFrequency1',Fstop1,... 'StopbandFrequency2',Fstop2,... 'PassbandFrequency1',Fpass1,... 'PassbandFrequency2',Fpass2,... 'SampleRate',Fs); fvtool(bpFilt,'Analysis','freq')
fvtool(b
,a
)
fvtool(
opens FVTool
and displays the magnitude response of the digital filter defined with numerator
b
,a
)b
and denominator a
.
fvtool(sos
)
fvtool(
opens FVTool and displays the
magnitude response of the digital filter defined by the L-by-6 matrix of
second order sections:sos
)
The rows of sos
contain the numerator and denominator coefficients
bik and
aik of the cascade of second-order sections of
H(z):
The number of sections, L, must be greater than or equal to 2. If the
number of sections is less than 2, fvtool
considers the input to be a
numerator vector.
fvtool(d
)
fvtool(
opens FVTool and displays the
magnitude response of a digital filter, d
)d
. Use designfilt
to generate d
based on frequency-response
specifications.
fvtool(b1,a1,b2,a2,...,bN,aN)
fvtool(b1,a1,b2,a2,...,bN,aN)
opens FVTool and displays the
magnitude responses of multiple filters defined with numerators b1
, …,
bN
and denominators a1
, ...,
aN
.
fvtool(sos1
,sos2
,...,sosN
)
fvtool(
opens FVTool and displays the magnitude responses of multiple filters defined with second
order section matrices sos1
,sos2
,...,sosN
)sos1
, sos2
, ...,
sosN
.
fvtool(Hd
)
fvtool(
opens FVTool and displays the
magnitude responses for the Hd
)dfilt
filter object Hd
or the array of dfilt
filter objects.
fvtool(Hd1
,Hd2
,...,HdN
)
fvtool(
opens FVTool and displays the magnitude responses of the filters in the
Hd1
,Hd2
,...,HdN
)dfilt
objects Hd1
, Hd2
,
..., HdN
.
h
= fvtool(___)
returns a figure
handle h
= fvtool(___)h
. You can use this handle to interact with FVTool from the
command line. See Controlling FVTool from the MATLAB Command Line.
FVTool has two toolbars:
An extended version of the MATLAB® plot editing toolbar. The following table shows the toolbar icons specific to FVTool:
Icon | Description |
---|---|
![]() | Restore default view. This view displays buffer regions around the data and shows only significant data. To see the response using standard MATLAB plotting, which shows all data values, use View > Full View. |
![]() | Toggle legend |
![]() | Toggle grid |
![]() | Link to Filter Designer (appears only if FVTool was started from Filter Designer) |
![]() ![]() | Toggle Add mode/Replace mode (appears only if FVTool was launched from Filter Designer) |
Analysis toolbar with the following icons:
![]() | Magnitude response of the current filter. See To see the zero-phase response, right-click the y-axis label of the Magnitude plot and select Zero-phase from the context menu. |
![]() | Phase response of the current filter. See |
![]() | Magnitude response and the phase response of the current filter
superimposed on one another. See |
![]() | Group delay of the current filter. Group delay is the average delay
of the filter as a function of frequency. See |
![]() | Phase delay of the current filter. Phase delay is the time delay the
filter imposes on each component of the input signal. See |
![]() | Impulse response of the current filter. The impulse response is the
response of the filter to an impulse input. See |
![]() | Step response of the current filter. The step response is the
response of the filter to a step input. See |
![]() | Pole-zero plot, which shows the pole and zero locations of the
current filter on the z-plane. See |
![]() | Filter coefficients of the current filter, which depend on the filter structure (direct-form or lattice) in a text box. For SOS filters, each section is displayed as a separate filter. |
![]() | Detailed filter information. |
In the Filter Designer app, selecting View > Filter Visualization Tool or the Full View Analysis toolbar button
when an analysis is displayed starts FVTool for the current
filter. You can synchronize Filter Designer and FVTool with the toolbar
button
. Any changes made to the filter in Filter
Designer are immediately reflected in FVTool.
Two link modes are provided via the toggle toolbar button /
:
Replace — removes the filter currently displayed in
FVTool and inserts the new filter.
Add — retains the filter currently displayed in
FVTool and adds the new filter to the display.
You can overlay a second response on the plot by selecting Analysis > Overlay Analysis and selecting an available response. A second y-axis is added to the right side of the response plot. The Analysis Parameters dialog box shows parameters for thex-axis and both y-axes. See Display Analysis Parameters for a sample Analysis Parameters dialog box.
You have a modified version of this example. Do you want to open this example with your edits?