clear;close all
N = 256
n = [0:N-1].';
k = [0:N-1].';
f = [0:N-1].'/N;

H0 = [ones(N,1)];
figure
subplot(2,1,1);bar(f,H0);axis tight

h0 = real(ifft(H0));
subplot(2,1,2);bar(n,h0);axis tight

sum(abs(imag(ifft(H0))))

H2 = [ones(49,1);zeros(N-49-48,1);ones(48,1)];
figure
subplot(2,1,1);bar(f,H2);axis tight
h2 = real(ifft(H2));
subplot(2,1,2);bar(n,h2);axis tight

sum(imag(ifft(H2)))

H2d = [ones(49,1);zeros(N-49-48,1);ones(48,1)].*exp(j*2*pi*f*N/2);
figure
subplot(2,1,1);bar(f,abs(H2d));axis tight
h2d = real(ifft(H2d));
subplot(2,1,2);bar(n,h2d);axis tight

sum(imag(ifft(H2d)))

H1 = [ones(25,1);zeros(N-25-24,1);ones(24,1)].*exp(j*2*pi*f*N/2);
figure
subplot(2,1,1);bar(f,abs(H1));axis tight
h1 = real(ifft(H1));
subplot(2,1,2);bar(n,h1);axis tight

sum(imag(ifft(H1)))

H3 = [ones(5,1);zeros(N-5-4,1);ones(4,1)].*exp(j*2*pi*f*N/2);
figure
subplot(2,1,1);bar(f,abs(H3));axis tight
h3 = real(ifft(H3));
subplot(2,1,2);bar(n,h3);axis tight

sum(imag(ifft(H3)))

