Products & Services Solutions Academia Support User Community Company

Learn more about Signal Processing Toolbox   

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.

  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  

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:

    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 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;                   % Initialize random number generator
    Nx = 100000;            % Number of noise data points
    xw = randn(Nx,1);       % Create white 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) 
    

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

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS