I am trying the DC blocking function in matlab. The algorithm of DC blocking is to find DC of the signal first and then remove the DC value from the signals. Here are the codes I tried, which are sample codes from Matlab:
t = (0:0.001:10000)'; x = sin(30*pi*t) + 1; hDCBlock1 = dsp.DCBlocker('Order', 4); % IIR is default hDCBlock2 = dsp.DCBlocker('Algorithm', 'FIR', 'Length', 100); hDCBlock3 = dsp.DCBlocker('Algorithm', 'Subtract mean'); for idx = 1 : 10 range = (1:1000) + 1000*(idx-1); y1 = step(hDCBlock1, x(range)); y2 = step(hDCBlock2, x(range)); y3 = step(hDCBlock3, x(range)); end plot(t(1:1000),x(1:1000),... t(1:1000),y1, ... t(1:1000),y2, ... t(1:1000),y3); legend(sprintf('Input DC:%.3f', mean(x)), ... sprintf('IIR DC:%.3f', mean(y1)), ... sprintf('FIR DC:%.3f', mean(y2)), ... sprintf('Subtract mean DC:%.3f', mean(y3)));
I tried to adjust the length of data and order of the IIR, the DC given by IIR always returns a bias error. However the FIR and mean does not, or gives very little errors.
Could anyone explain on this?