x=ecg(500)'+0.25*randn(500,1); %noisy waveform h=fdesign.lowpass('Fp,Fst,Ap,Ast',0.15,0.2,1,60); d=design(h,'equiripple'); %Lowpass FIR filter y=filtfilt(d.Numerator,1,x); %zero-phase filtering y1=filter(d.Numerator,1,x); %conventional filtering
You are correct that if you do convolution, you get a sequence longer than your original signal. However, those extra samples are actually the output due to the internal filter states. I would suggest you to compare the following three results:
x = ones(10,1); h = ones(10,1); y1 = conv(h,x); y2 = filter(h,x); [y3, zf] = filter(h,x);
You can see that y1 is basically the combination of y3 and zf. It is worth noting that this is only true for a direct form II transposed implementation, but nevertheless it captures the idea. In some sense, you can think that the extra samples you got from convolution is as if the next input is all zero. In real applications, such scenario rarely happens. In addition, it is often the case that one needs to filter continuous data blocks, therefore, the filter needs to retain the original state so that it can properly filter the next data block. This is why the filter command gives the output the same length as the input.
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.