Bertrand
Bertrand

Reputation: 43

Matlab FIR Filter

I have to analyse the coefficients for a Finite Impulse Response (FIR) filter for minimal word lengths so there should be no internal overflows that impact to the output.

-0.0041 0.0077 0.0893 0.3276 0.0893 0.0077 -0.0041

I have tried

f = fdesign.bandpass(0.0041,0.0077,0.0893,0.3276, 0.0893, 0.0077,0.0041);
Hd = design(f, 'equiripple');
fvtool(Hd)

I get the following error:

Frequency specifications must be between 0 and 1.

Then I calculated Scale factor and multiplied all coefficients

coefficients  h[0] +  h[1] +  h[2] +…+  h[M] = S

Log base 2 (S )+ 1

but still I am getting the same error:

Frequency specifications must be between 0 and 1.

Upvotes: 2

Views: 1040

Answers (1)

SleuthEye
SleuthEye

Reputation: 14579

fdesign.bandpass can be used to design bandpass filter from filter specifications including parameters such as:

  • frequency at the edge of the start of the first stop band
  • frequency at the edge of the start and end of the passband
  • frequency at the edge of the start of the second stop band
  • attenuation in the stop bands
  • amount of ripple allowed in the pass band
  • filter order

What you have appears to be filter coefficients rather than filter specifications based on the parameters above. To create a filter object with these coefficients, you may use one of many available structure options from dfilt. In your case an appropriate structure for a FIR filter would be dfilt.dffir:

b = [-0.0041,0.0077,0.0893,0.3276, 0.0893, 0.0077,-0.0041];
Hd = dfilt.dffir(b);
fvtool(Hd)

Upvotes: 4

Related Questions