Documentation

FVTool

Filter Visualization Tool

描述

Filter Visualization Toolis 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 withFile>Export.

If the DSP System Toolbox™ product is installed,FVToolcan also visualize the frequency response of a filter System object™. If you need to filter streaming data in real time, using System objects is the recommended approach. For more information, seefvtool.

Open the FVTool

TheFVToolcan be opened programmatically using one of the methods described inProgrammatic Use.

Examples

expand all

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 selectingAnalysis > 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: [346.5000 282.5000 583 437] 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: [346.5000 282.5000 583 437] 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: [346.5000 282.5000 583 437] 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)
网格:‘上’传说:‘上’AnalysisToolbar:”“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] 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: [1.3350 3.3150 5.8300 4.3700] PaperPositionMode: 'auto' PaperSize: [8.5000 11] PaperType: 'usletter' Pointer: 'arrow' PointerShapeCData: [16x16 double] PointerShapeHotSpot: [1 1] Position: [346.5000 282.5000 583 437] 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' UIContextMenu: [0x0 GraphicsPlaceholder] UserData: [] Visible: 'on' NormalizedFrequency: 'off' PhaseDisplay: 'Phase' NumberofPoints: 8192 PhaseUnits: 'Radians' FrequencyRange: '[-Fs/2, Fs/2)' OverlayedAnalysis: '' Analysis: 'phase' FrequencyVector: [1x256 double] PolyphaseView: 'off' ShowReference: 'on' FrequencyScale: 'Linear'

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')

Related Examples

Programmatic Use

expand all

fvtool(b,a)opens FVTool and displays the magnitude response of the digital filter defined with numeratorband denominatora.

fvtool(sos)opens FVTool and displays the magnitude response of the digital filter defined by theL-by-6 matrix of second order sections:

sos = [ b 01 b 11 b 21 1 a 11 a 21 b 02 b 12 b 22 1 a 12 a 22 b 0 L b 1 L b 2 L 1 a 1 L a 2 L ] .

The rows ofsoscontain the numerator and denominator coefficientsbikandaikof the cascade of second-order sections ofH(z):

H ( z ) = g k = 1 L H k ( z ) = g k = 1 L b 0 k + b 1 k z 1 + b 2 k z 2 1 + a 1 k z 1 + a 2 k z 2 .

The number of sections,L, must be greater than or equal to 2. If the number of sections is less than 2,fvtoolconsiders the input to be a numerator vector.

fvtool(d)opens FVTool and displays the magnitude response of a digital filter,d. Usedesignfiltto generated基于frequency-response specifications.

fvtool(b1,a1,b2,a2,...,bN,aN)opens FVTool and displays the magnitude responses of multiple filters defined with numeratorsb1, …,bNand denominatorsa1, ...,aN.

fvtool(sos1,sos2,...,sosN)opens FVTool and displays the magnitude responses of multiple filters defined with second order section matricessos1,sos2, ...,sosN.

fvtool(Hd)opens FVTool and displays the magnitude responses for thedfiltfilter objectHdor the array ofdfiltfilter objects.

fvtool(Hd1,Hd2,...,HdN)opens FVTool and displays the magnitude responses of the filters in thedfiltobjectsHd1,Hd2, ...,HdN.

h= fvtool(___)returns a figure handleh. You can use this handle to interact with FVTool from the command line. SeeControlling FVTool from the MATLAB Command Line.

More About

expand all

Introduced before R2006a