how to generate a filter code including coefficients?

조회 수: 8 (최근 30일)
Qingshan
Qingshan 2017년 3월 2일
댓글: Qingshan 2017년 3월 3일
I would like to generate custom Matlab codes with Zero phase filter (filtfilt) like generateFilteringCode(FC). How can I do it? With generateFilteringCode(FC), a matlab function is generated with the filter coefficients. I would like to generate or program a matlab function for Zero phase filter, however, I have no idea how to including into the filter coefficients like a function generated from generateFilteringCode(FC). Any advice? Many thanks
Qingshan

답변 (1개)

Meade
Meade 2017년 3월 2일
Qingshan,
Based on you question, it seems like you really have 2 needs:
#1) Calculate the filter coefficients for a particular scenario & filter type (e.g. fir, iir, etc etc)
#2) Apply the coefficients to a signal such that you will see no phase-shift in the output.
For question 1, check out designfilt. This will help you calculate the necessary coefficients. I have also written a wrapper function for the old SAE-J211 low pass filters . It might give you an idea of how to do it.
For question 2, once you have your coefficients, you can use filtfilt if you have the "Signal Processing Toolbox". If you do not, check out the excellent function FilterM by Jan Simon. It works with lots for lots of applications and doesn't need any toolboxes.
  댓글 수: 1
Qingshan
Qingshan 2017년 3월 3일
Many thanks your answer, but it does not answer my question. The filter coefficients have been obtained from an adaptive filter I coded with matlab. The fir filters also generated with Matlab function of 'generateFilteringCode(FC, FNAME)'. For example: function y = Compensator_ASIO__MADIface__USB_CH2_SR44100(x) persistent filter1 if isempty(filter1) filter1 = dsp.FIRFilter( ... 'Numerator', [1.3108856014649495 -0.8207824972645964 0.27940336027304113 0.25277918497773888 -1.007908990032466 712598101 0.0057817321447415403 0.038899930313334316 0.038806410908364418 0.0039870999192148831 0.01136378621031286]); end y = step(filter1,x );
However, I would like to generate zero phase filters with the filter coefficients. Would you have any idea how to do it?
Thanks Qingshan

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

카테고리

Help CenterFile Exchange에서 Get Started with DSP System Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by