How to calculate the filter order of given specification ??

Hi, i designed a filter using :
d1=designfilt('lowpassfir','PassbandFrequency',0.45,'StopbandFrequency',0.5,'PassbandRipple',3,'StopbandAttenuation',60,'DesignMethod','equiripple');
When i tried to use fdatool to get the filter coefficient i need to put the filter order but i don't know how to calculate it . can anyone tell me please?

 채택된 답변

Star Strider
Star Strider 2017년 7월 7일

0 개 추천

There is a way to calculate the order necessary for IIR filters, since they have both numerator and denominator polynomials, but not for FIR filters, with only numerator polynomials. With FIR filters, I usually begin with a filter order of 24, then use freqz to test it, and increase the length until I get the result I want. The window you choose will affect the filter passband shape.

댓글 수: 17

Is there any other way to extact the filter coefficients because i found that i can use sos = lpfilt.Coefficients but they said that this function "Output the filter coefficients, expressed as second-order sections." and i don't undestand what does this mean :expressed as second-order sections??
The second-order-section form produces the most stable filter implementation, so that is preferable.
If you want to convert the second-order-second representation to a transfer function so that you can get the filter coefficients, use the sos2tf function.
afef
afef 2017년 8월 16일
편집: afef 2017년 8월 16일
Yes, actually i just want to get the coefficients of the filter that i used with
d1=designfilt('lowpassfir','PassbandFrequency',0.45,'StopbandFrequency',0.5,'PassbandRipple',3,'StopbandAttenuation',60,'DesignMethod','equiripple');
a = filtfilt(d1,deriv1);
because i need to implement this filter in c langage so how is it possible to generate c code in Matlab for filtfilt
i use the sos2tf but i got this error message SOS matrix must have six columns.
I am lost. The second-order-section representation should have the necessary 6 columns.
Check to see what the function is actually returning.
When I run this:
d1=designfilt('lowpassfir','PassbandFrequency',0.45,'StopbandFrequency',0.5,'PassbandRipple',3,'StopbandAttenuation',60,'DesignMethod','equiripple');
Coefs = d1.Coefficients;
the ‘Coefs’ variable is a vector of 61 coefficients for your FIR filter, so this may be all you need to do.
when i run it i got 66 coefficients . Conceerning the use of the filtfilt which have the syntax y = filtfilt(b,a,x). so for my case coefs =b and a=1 because it is a FIR ? am i right?
‘so for my case coefs =b and a=1 because it is a FIR ? am i right?’
Yes.
Sorry to ask that but really i'm very lost and confused because i should implement this filter that i used in c langage and i couldn't find any code c for this so if you have any idea can you help me ? and if i just look for low pass fir filter it dosen't matter ? Thanks for replying
My pleasure.
I have not programmed in C in many years. Unfortunately, I cannot help you with C code.
ok no problem Thanks
My pleasure.
I would look through Numerical Recipes in C by Press, et al. to see if a filter algorithm of some type exists already. You may have to adapt an algorithm to code the filtfilt function.
Ok i will do that, thanks for the advice.
Another question please i want to know does the filter coefficients change with the length of the signal because i have a signal with a lenght 2560 and i will partion it to 4 parts and i use for each part the same filter coefficients so is this right?
The filter coefficients will be whatever you designed them to be, and do not change with the length of the signal. Your filter has a length of about 64 if I remember correctly, and your signal segments will be 640. You should not have any problems with it.
You could get transients at the beginning and end of each segment. For this reason, I would partition the signal after filtering to get the best results.
My filter length is about 66. Actually i need to partion my signal like this because i need to implement in a processor which cannot handle the all length of the signal,that's why i asked to just clarify is there a problem with that.
The only problem are the (possible) filter transients at the beginning and end of each segment. These are more apparent with longer filters.
Ok, i undestand thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Digital and Analog Filters에 대해 자세히 알아보기

질문:

2017년 7월 7일

댓글:

2017년 8월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by