FIR Filter in MATLAB

I've seen in MATLAB FIR Filter, that we can use the function 'designfilt', to obtain value from Filter coefficients regarding some specification(cut off frequency, order, etc...). My question is, on the other side, if we already have the filter coefficients, let's say 1x31 coefficients vektor, can we retrieve its specifications(order,cutoff frequency,ripple...)? Maybe using a function in MATLAB,which is i'd like to know.

Answers (1)

Star Strider
Star Strider on 30 Nov 2016

0 votes

Use the freqz function to get the transfer function. You would have to calculate the ripple yourself, but that is not difficult. (The findpeaks function would help with that.) The order is the order of the denominator polynomial. You would have to know the sampling frequency to get the cutoff frequency in Hz, although it would again be straightforward to calculate it in radian frequency (on the interval (0,pi)) from the transfer function.

8 Comments

Thanks btw for your reply. You're right,when we want to use the function 'freqz', i can get the cut off freq(regarding its Fs/2), Ripple and Attenuation. Thanks
And i've still one more question. If i want to obtain the same filter coefficients(lets say-->A) using the same specifications (cut off, fs,etc.) using 'designfilt' FIR-Filter function, do you have some advice? because i've tried to use fir1, fir2 with the same specification(cut off, fs,etc) then get the filter coefficients (lets say B),but they'd(fir1,fir2) never have filter coefficients same as A.
Has anyone advices?
My pleasure.
You would have to know how ‘A’ was designed. You can design a filter that has essentially identical characteristics as ‘A’ and have different coefficients.
It is almost impossible to ‘reverse engineer’ a filter to recover the exact characteristics used to design it. That information would probably allow you to reproduce it exactly, but without that information, you have to settle for reproducing it as accurately as possible.
thanks very much
My pleasure.
Regarding the function findpeaks in MATLAB, in my opinion can't be used to calculate Ripple in Filter passband. Findpeaks defines only the maxima and minima's peaks value, which means if there are more than one value in maxima, findpeaks function only show its means value.
That’s not true for findpeaks. It has many name-value pair argument sets that make it very useful. Used with some of the set membership functions such as setdiff and ismember, it can find the peak of the passband maximum and the peaks of the ripple values, so calculating the ripple amplitude and converting that to dB is straightforward.
Calculating the cutoff frequencies for the passbands and stopbands is likewise straightforward, although for this, the interp1 function is best. It requires some programming, experimentation, and time, but is not difficult.
Please explore these functions. The documentation is clear, and if you have problems, we can help. Remember that freqz returns the complex transfer function, so use the abs function to convert it to magnitude values.
I see. Thanks so much for your explanation.
Ive never actually use the interp1 before. but i'd explore this function first. thanks
My pleasure.

Sign in to comment.

Asked:

on 30 Nov 2016

Commented:

on 5 Dec 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!