close all



x=zeros(1,1000);
x(1:50)=1;
x(end-50+1:end)=1;


fq=linspace(-500,500,1000);
y=ifft(x);
subplot(411)
plot(fq,fftshift(x));
xlabel('ideal lopass filter in frequency domain')
subplot(412)
plot(fq,real(fftshift(y)))
xlabel('ideal filter coeffs in time domain')


subplot(413)
yy=zeros(size(y));
y=fftshift(y);
y=y(end/2-50:end);
yy(1:length(y))=y;
yy(100:end)=0;
plot(real(yy))
xlabel('truncated causal filter')

subplot(414)
xx=fft(yy);
plot(fq,abs(fftshift(x)),'r')
hold on
plot(fq,abs(fftshift(xx)));


xlabel('Gibbs phenomenon')





