0% found this document useful (0 votes)
78 views

Appendix Data Base Control

Data Base GUI
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

Appendix Data Base Control

Data Base GUI
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

3

Filter Design with the


FDATool GUI

Introduction (p. 3-2) Overview of filtering using Signal


Processing Toolbox™ GUIs
Designing the Filter (p. 3-3) Details of designing a filter using
FDATool
Analyzing the Filter (p. 3-8) Viewing different filter responses in
FDATool
Designing Additional Filters (p. 3-10) Creating more filters in FDATool
Viewing and Annotating the Filter Using the FVTool GUI to view and
(p. 3-11) annotate the filter
Exporting Filters from FDATool Exporting the filter designs as
(p. 3-17) objects
Using Discrete Filter Objects (dfilts) Using discrete filter objects
(p. 3-19)
Where to Find More Information Finding more information and more
(p. 3-22) complex examples
3 Filter Design with the FDATool GUI

Introduction
This section describes how to graphically design and implement digital
filters using the Signal Processing Toolbox™ FDATool GUI. Filter design
is the process of creating the filter coefficients to meet specific frequency
specifications. Filter implementation involves choosing and applying a
particular filter structure to those coefficients. Only after both design and
implementation have been performed can your data be filtered.

Although many methods exist for designing the filter coefficients, this chapter
focuses on using the basic features of the Filter Design and Analysis Tool
(FDATool) GUI. For filter implementation, this chapter uses dfilt.

This section includes a brief discussion of applying the completed filter design
and filter implementation using MATLAB® command line functions, such as
filter.

For an interactive FDATool demo, type demos at the MATLAB command


line, and select Toolboxes. Expand the tree, scroll down, and select Signal
Processing Toolbox. Under Filter Design and Analysis, click Introduction
to Filter Design and Analysis Tool.

3-2
Designing the Filter

Designing the Filter


This section is a step-by-step introduction to using the Filter Design and
Analysis Tool (FDATool) to design an octave-band filter. An octave is the
interval between two frequencies having a ratio of 2:1. An octave-band filter
is a bandpass filter with high cutoff frequency approximately twice that of the
low cutoff frequency. The class of an octave filter is determined by its allowable
passband ripple and its stopband attenuation. Refer to the ANSI S1.11–2004
standard for more information. For more information on designing filters, see
“FDATool: A Filter Design and Analysis GUI” in Signal Processing Toolbox™
User’s Guide. (Note that you can also access FDATool from SPTool).

1 Start FDATool from the MATLAB® command line.

fdatool

The FDATool dialog opens with a default filter. Its filter information is
summarized in the upper left (Current Filter Information) and its filter
specifications are depicted in the upper right. In addition to displaying
filter specification, this upper right pane displays filter responses and filter
coefficients.

3-3
3 Filter Design with the FDATool GUI

The bottom half of FDATool shows the Filter Design panel, where you
specify the filter parameters. Other panels, such as Import filter from
workspace and Pole/Zero Editor, which you access with the buttons on
the lower left, are also displayed in this area. If you have other products
installed, you may see additional buttons.

2 In the Response Type pane, select Bandpass.

3 In the Design Method pane, select IIR, and then select Butterworth
from the selection list.

3-4
Designing the Filter

4 For the Filter Order, select Specify order, and then enter 6.

5 Set the Frequency Specifications as follows:

Parameter Setting Description


Units Hz Units for the parameters
Fs 48000 Sampling frequency
Fc1 22 First cutoff frequency (i.e., the
frequency preceding the passband at
which the magnitude response is 3 dB
below the passband gain)
Fc2 45 Second cutoff frequency (i.e., the
frequency following the passband at
which the magnitude response is 3 dB
below the passband gain)

3-5
3 Filter Design with the FDATool GUI

6 After specifying the filter design parameters, click the Design Filter
button at the bottom of the design panel to compute the filter coefficients.
The display updates to show the magnitude response of the designed filter.

Notice that the Design Filter button is disabled after you compute the
coefficients for your filter design. This button is enabled again if you make
any changes to the filter specifications.

7 Click the Store Filter button.

3-6
Designing the Filter

8 In the Store Filter dialog, change the filter name to Bandpass


Butterworth-1 and click OK to save the filter in the Filter Manager.

3-7
3 Filter Design with the FDATool GUI

Analyzing the Filter


After designing the filter, you can view the following filter responses in the
display region by clicking on the associated toolbar button or by selecting the
desired response from the Analysis menu.

Response Toolbar Button Image


Magnitude response

Phase response

Magnitude and Phase responses

Group delay

Phase delay

Impulse response

Step response

Pole-zero plot

Filter coefficients

Filter information

Zero-phase response–only available from


a context menu. Right-click on the y-axis
of a Magnitude or Magnitude and Phase
response plot or select Analysis > Analysis
Parameters.

3-8
Analyzing the Filter

Note Other analyses are available if you have the Filter Design Toolbox™
product installed.

1 Examine the displayed magnitude response of the filter.

2 Display other responses, as desired. Click the appropriate buttons, shown


in the table above or select the desired response from the Analysis menu.

3 Click the Filter coefficients button to display the filter coefficients.

3-9
3 Filter Design with the FDATool GUI

Designing Additional Filters


You have designed one of the bands of an octave filter bank. This section shows
you how to design and save the other nine bands. The following table defines
the parameters for the remaining bands. Note that all of the bands use these
parameters: Bandpass, IIR – Butterworth , order = 6, Fs = 48000 Hz .

Fc1 Fc2 Filter Name


45 89 Bandpass Butterworth-2
89 178 Bandpass Butterworth-3
178 355 Bandpass Butterworth-4
355 708 Bandpass Butterworth-5
708 1413 Bandpass Butterworth-6
1413 2818 Bandpass Butterworth-7
2818 5623 Bandpass Butterworth-8
5623 11220 Bandpass Butterworth-9
11220 22387 Bandpass Butterworth-10

1 Using the parameters listed in the table above, for each table row, set the
appropriate the Fc1 and Fc2 values.

2 Design the filter by clicking the Design Filter button.

3 Click Store Filter to save the filter.

4 Change the name to the appropriate filter name shown in the table above.

5 Repeat these steps until all 10 filters are designed and stored.

3-10
Viewing and Annotating the Filter

Viewing and Annotating the Filter


In this section...
“Viewing the Filter in FVTool” on page 3-11
“Using FVTool for Annotation” on page 3-15

Viewing the Filter in FVTool


This section teaches you how to use the Filter Visualization Tool (FVTool) to
view the octave-band filter. It also describes how to annotate your filter.

1 Click the Filter Manager button to display the Filter Manager, which
lists your saved filters.

2 Press Ctrl+click on each filter name to select all the filters, and then
click FVTool. FVTool opens with the filter responses overlaid for easy
comparison. (If you want to view a single filter in FVTool, click the Full

3-11
3 Filter Design with the FDATool GUI

View Analysis button when that filter is shown in the FDATool display
panel or select View > Filter Visualization Tool).

3 Change the x-axis scale to logarithmic by selecting Analysis > Analysis


Parameters to display the Analysis Parameters dialog.

4 Change the Frequency Scale to Log.

5 Click OK.

3-12
Viewing and Annotating the Filter

6 Click the Legend button to turn on the legend, which you can drag to
the desired location.

3-13
3 Filter Design with the FDATool GUI

7 Click the Legend button again to turn off the legend.

Use the Zoom button and drag a rectangle around the first few
passbands to zoom in.

3-14
Viewing and Annotating the Filter

8 Click the Restore Default View button to return to the full view.

9 Display other responses, as desired. (The FVTool Analysis toolbar buttons


and Analysis menu are the same as in FDATool. See “Analyzing the Filter”
on page 3-8 for descriptions of the buttons.

Using FVTool for Annotation


FVTool is also useful for doing further analysis, adding annotations, and
printing. Available annotations include adding rectangles, text boxes, arrows
and lines, and adding data markers.

For a demo about FVTool, type demos at the MATLAB® command line,
and select Toolboxes. Expand the tree, scroll down, and select Signal
Processing Toolbox. Under Filter Design and Analysis, click Filter
Analysis using FVTool and its API.

3-15
3 Filter Design with the FDATool GUI

Note Do not close FDATool at this time. You will use it in future sections.

1 Use the toolbar buttons to annotate your response plot. Add a line by
clicking one of the line buttons, and then use your mouse to draw the line
on your plot.

2 Add a data maker by clicking on a plot at the desired point. The data
marker shows the frequency and magnitude at that point.

3 Close FVTool by selecting File > Close.

3-16
Exporting Filters from FDATool

Exporting Filters from FDATool


FDATool provides a simple way to create filter objects (dfilts) from your
filter designs. This is particularly useful for saving your filter design to the
MATLAB® workspace for use with command line functions. You can also
save your filters to M-files using File > Generate M-file to run in scripts
or batch files.

1 In FDATool, click Filter Manager and highlight only the Bandpass


Butterworth-1 filter.

2 Select File > Export.

3 Set Export to to Workspace. Set Export as to Objects. In Discrete


Filter type Hd1. Click Export to export the first filter in your filter bank to
an Hd1 dfilt object in the workspace.

4 Repeat steps 1 through 3 for each of the remaining nine filters. Highlight
each filter individually to make it the active filter and change the Discrete
Filter name to match the filter number. When you finish you will have
10 dfilt objects in the workspace.

3-17
3 Filter Design with the FDATool GUI

5 Close FDATool by selecting File > Close.

6 On the MATLAB command line, verify that your objects were exported by
using the whos command.

whos
Name Size Bytes Class Attributes

Hd1 1x1 dfilt.df2sos


Hd10 1x1 dfilt.df2sos
Hd2 1x1 dfilt.df2sos
Hd3 1x1 dfilt.df2sos
Hd4 1x1 dfilt.df2sos
Hd5 1x1 dfilt.df2sos
Hd6 1x1 dfilt.df2sos
Hd7 1x1 dfilt.df2sos
Hd8 1x1 dfilt.df2sos
Hd9 1x1 dfilt.df2sos

3-18
Using Discrete Filter Objects (dfilts)

Using Discrete Filter Objects (dfilts)


In this section...
“Using dfilt Objects” on page 3-19
“Filtering with dfilt” on page 3-19

Using dfilt Objects


In the previous section, you created dfilt objects containing your filters. In
this section, you explore some dfilt command line methods. See the dfilt
reference page for descriptions of all available methods. dfilts are also used
in Filter Design Toolbox™ and Filter Design HDL Coder™ products, which
extend the capabilities of Signal Processing Toolbox™ functions and GUIs.

For an interactive demo about dfilts, type demos at the MATLAB® command
line, and select Toolboxes. Expand the tree, scroll down, and select Signal
Processing Toolbox. Under Filter Design and Analysis, click Getting
Started with Discrete-Time Filter Objects.

Filtering with dfilt


1 Type the following on the MATLAB command line to concatenate your
filter bank filter objects into a single dfilt object.

Hd = [Hd1 Hd2 Hd3 Hd4 Hd5 Hd6 Hd7 Hd8 Hd9 Hd10];

2 To view the first filter, type Hd(1).

Hd(1)

ans =
FilterStructure: 'Direct-Form II, Second-Order Sections'
sosMatrix: [3x6 double]
ScaleValues: [3.40097054256801e-009;1;1;1]
PersistentMemory: false

3 A number of methods can be used to view and manipulate the Hd1 dfilt
object. Try the info command:

3-19
3 Filter Design with the FDATool GUI

info(Hd1) % Displays filter information

Discrete-Time IIR Filter (real)


-------------------------------
Filter Structure : Direct-Form II, Second-Order Sections
Number of Sections : 3
Stable : Yes
Linear Phase : No

4 You can open FVTool from the MATLAB command line and specify display
parameters as follows.

F = fvtool(Hd,'Analysis','magnitude') % Open FVTool with


% magnitude display
set(F,'FrequencyScale','Log') % Change to log scale

This produces the same display as step 5 of “Viewing the Filter in FVTool”
on page 3-11 above.

5 Now using the MATLAB command line, create some discrete white
Gaussian noise data, which you can then filter using the filter bank.

rand('state',0); % Initialize random number generator


Nx = 100000; % Number of noise data points
xw = randn(Nx,1); % Create whtie noise
for i=1:10,
yw(:,i)=filter(Hd(i),xw); % Filter the white noise through
end % the entire filter bank.
% (:,i) means all rows of column i

Note Do not delete this filtered data. You will use it in the Spectral
Analysis section.

6 Plot the filtered data.

plot(yw)

3-20
Using Discrete Filter Objects (dfilts)

The next section discusses spectral analysis, where you analyze this data.

3-21
3 Filter Design with the FDATool GUI

Where to Find More Information


The previous sections described how to use the fundamental features of
FDATool, FVTool, and the dfilt command. For more advanced information
and more complex examples, refer to other sections of Signal Processing
Toolbox™ online help or Signal Processing Toolbox documentation available
on The MathWorks Web site (www.mathworks.com).

3-22

You might also like