Filter löschen
Filter löschen

how to generate a filter code including coefficients?

4 Ansichten (letzte 30 Tage)
Qingshan am 2 Mär. 2017
Kommentiert: Qingshan am 3 Mär. 2017
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

Antworten (1)

Meade am 2 Mär. 2017
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 Kommentar
Qingshan am 3 Mär. 2017
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

Melden Sie sich an, um zu kommentieren.


Mehr zu Get Started with DSP System Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by