Hello，I have design an filter by the function designfilt and I have get the filter object. And I need to conver the filter to a C language version, so I plan to get the numerator(b) and denominator(a) coefficients of my filter and then implement the filter by C language base the coeficients. But after I get the numerator and denominator coefficients of filter object by the function "tf" and I filter the orgin signal by "filter(b,a,signal)" on matlab, it is not equivalent to using filter object directly. Here is my source code. Dose anyone know how to fix this?
sig1 = sin(2 * pi * 5 * t);
sig2 = cos(2 * pi * 20 * t);
lpFilt = designfilt('lowpassiir', 'PassbandFrequency', 8, ...
'StopbandFrequency', 10, 'PassbandRipple', 0.5, 'SampleRate', fs, ...
'StopbandAttenuation', 65, 'DesignMethod', 'butter');
dataFilteredOut1 = filter(lpFilt, signal);
dataFilteredOut2 = filter(b, a, signal);