| Filter Design Toolbox | ![]() |
iirlpnorm Examples
Each of these examples uses one or more feature provided in the function iirlpnorm. The examples build on one another, although they can be run separately. Review each example to get an overview of the capabilities of the function.
Example -- Using iirlpnorm to Design a Lowpass Filter
To design a lowpass filter with maximum gain of 1.6 in the passband, we use the syntax iirlpnorm(n,d,f,edges,a,w). To duplicate the filter in the figure, use this code.
[b,a]=iirlpnorm(3, 11, [0 0.15 0.4 0.5 1], [0 0.4 0.5 1],... [1 1.6 1 0 0], [1 1 1 100 100]); [h,w,s]=freqz(b,a,1024); s.plot = 'mag'; s.yunits = 'linear'; freqzplot(h,w,s); hold on; plot([0 0.15 0.4 0.5 1], [1 1.6 1 0 0], 'r'); hold off;
When you look at the magnitude response curve, notice the response reaches 1.6 in the passband.
Example -- Using iirlpnorm to Design a Low Order Filter
The curves in the next figure show the results of using iirlpnorm to design a low-order filter with a single band. For this design, we introduce a new two-element vector P=[Pmin,Pmax] that defines the minimum and maximum values of P in the least-pth norm algorithm. If you do not specify P, the default values are [2 128], resulting in the L
or Chebyshev norm. Specify Pmin and Pmax to be even numbers. To view the placement of the poles and zeros for your filter before the optimization takes place, replace [Pmin Pmax] with the string 'inspect'. With the option 'inspect' in use, the algorithm does not optimize the filter design.
We specified a lowpass filter with third-order numerator and denominator, and used the P vector to limit the optimization range, by using the function syntax iirlpnorm(n,d,f,edges,a,w,p).
[b,a]=iirlpnorm(3, 3, [0 .2 .6 .8 1], [0 1], [0 .4 .2 0 1],... [1 1 1 1 1], [2 64]); [h,w,s]=freqz(b,a,1024); s.plot = 'mag'; s.yunits = 'linear'; freqzplot(h,w,s); hold on; plot([0 .2 .6 .8 1], [0 .4 .2 0 1], 'r'); hold off;
Setting W=[1 1 1 1 1] is the same as not setting weight values.
Example -- Using iirlpnorm to Design a Bandstop Filter
Designing IIR bandstop filters is straightforward. Enter the frequency, magnitude, edges, and weight vectors using the syntax iirlpnorm(n,d,f,edges,a,w) as shown here. To ensure that the stopband rejects undesired frequencies aggressively, we weight the magnitude response in the stopband more heavily by entering the weight vector [1 1 5 5 1 1], telling the optimization algorithm that meeting the inband response specification is five times as important as meeting the out-of-band response.
[b,a]=iirlpnorm(10, 7, [0 .25 .35 .7 .8 1],... [0 .25 .35 .7 .8 1], [1 1 0 0 1 1], [1 1 5 5 1 1]); [h,w,s]=freqz(b,a,1024); s.plot = 'mag'; s.yunits = 'linear'; freqzplot(h,w,s); hold on; plot([0 .25 .35 .7 .8 1], [1 1 0 0 1 1], 'r'); hold off;
As you can see from the following figure, the filter meets our design needs quite closely.
Example -- Using iirlpnorm to Design a Noise-Shaping Filter
In this example, we create a lowpass filter with a rising magnitude in the passband. Communications designers use the filter when they simulate the effects of motion between a transmitter and receiver, such as you find in cellular telephone networks. Here, we use iirlpnorm to design the same filter. Because of the complex shape of the passband, we define the vectors f, a, w, and edges in the workspace, then use the vector names in the iirlpnorm statement.
f = 0:0.01:0.4; a = 1.0 ./ (1 - (f./0.42).^2).^0.25; f = [f 0.45 1]; a = [a 0 0]; edges = [0 0.4 0.45 1]; w = ones(1, length(a)); [b,a]=iirlpnorm(4, 6, f, edges, a, w); [h,w,s]=freqz(b,a,1024); s.plot = 'mag'; s.yunits = 'linear'; freqzplot(h,w,s); hold on; plot(F,A, 'r'); hold off;
When you compare the figure below to the filter design in Getting Started with the Toolbox, you see they match very well.
| Advanced IIR Filter Designs | iirlpnormc Examples | ![]() |
Learn more about the latest releases of MathWorks products: |
| © 1994-2010 The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |