Question
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.
Expert Answer
John Michell
PhD Expert
Answered Aug 14, 2026
Documentation on the FILTFILT function is missing important information regarding its performance.
Here is additional information on the FILTFILT function.
The length of the input 'x' must be more than three times the filter order, defined as max(length(b)-1,length(a)-1). The input should be sufficiently large so that the impulse is correctly represented.
As an example, for a fifth order filter, if the input sequence is a delta sequence, the '1' should appear anywhere within the first 15 samples.
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;
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related matlab Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →