# DSP finite impulse response (MATLAB)

I designed the filter below on paper:

FIR
low pass
type 1
length 3
alpha = 6
beta = -12
allow freq. <= 0.1rad/sample
blocked freq. >= 0.4rad/sample


To confirm that my calculations are correct I was planning to design the filter on MATLAB. Is there a function to design this filter, apply an input frequency and check the output result?

• What is alpha and beta? – Matt L. May 11 '15 at 16:07
• Sorry for not explaining. h[0] = ∝ h[1] = β h[2] = ∝ therefore: H(ejw) = ∝ + β e^-j1w + ∝ e^-j2w – dritech May 11 '15 at 21:04
• Also, type 1 is the symmetry type. Type 1 is when the order is odd and the number of samples is even. – dritech May 11 '15 at 21:08
• @MattL. Please see replies above. Thanks – dritech May 11 '15 at 22:45
• @dritech : Please add your solution as an answer below, and accept it (once the system lets you). It will possibly help others with similar problems. – Peter K. Sep 8 '15 at 18:49

## 1 Answer

Like Matt L. pointed out, alpha and beta is unclear as is 'type 1'.

You can use the command fdatool to interactively design filters in MATLAB, although you may need the DSP system toolbox installed.

From there, you can apply the filter using the filter() function.

As an example, if you design the filter using FDAtool, and the filter is an FIR, you can use filter(Hd.numerator,1,X,Fs) if Hd is your filter object, X is the input sequence, and Fs is your sampling rate. This is not the only way to do this, but just the way I would go about it.

X could be generated as a sin(2*pinf*t) where t = 1/fs and n is an index in a for loop or shortened to 1:ns for the number ns you wish to have your input sequence have as a length.