Why does the FILTFILT documentation not mention the effects of truncation, while providing a short input sequence to an IIR filter ? I am using the FILTFILT function to plot the magnitude response. I observe a truncated output when using a short delta sequence. However, if I increase the filter order or the length of the input sequence, I get an improved response. The documentation does not provide any information regarding this.
John Michell answered .
2025-11-20
close all; [b,a] = butter(5,0.5); % a = 1; delta = [zeros(2,1);1;zeros(100,1)]; % Short Input vector y_short = filtfilt(b,a,delta); Y_short = fft(y_short,2048); delta_long = [zeros(1024,1);1;zeros(1023,1)]; %Long Input vector y_long = filtfilt(b,a,delta_long); Y_long = fft(y_long,2048); figure; impz(b,a,length(delta)); hold on; plot(sqrt(abs(y_short)),'r'); figure; impz(b,a,length(delta_long));hold on; plot(sqrt(abs(y_long)),'r'); w = linspace(0,2*pi,length(delta)); wl = linspace(0,2*pi,length(delta_long)); h1 = freqz(b,a,wl); figure; plot(wl,abs(h1)); hold on; plot(wl,sqrt(abs(Y_short)),'r'); hold off; h_long = freqz(b,a,wl); figure; plot(wl,abs(h_long)); hold on; plot(wl,sqrt(abs(Y_long)),'r'); hold off;