clear all; close all;

fp = 1000;
f1 = 100;
f2 = 250;
f0 = 150;

N = 15; 
NS = 10*N;
    wg = 2*pi*f0/fp;

    % impulse response
    n=-N:-1;
    h = sin(wg*n)./(pi*n);
    n=1:N;
    h = [h, wg/pi, sin(wg*n)./(pi*n)];
    n = -N:N;
    stem(n, h);
    
    %frequency response
    w = linspace(-pi, pi, 500);
    Nw = length(w);
    H_rect = zeros(1, Nw);
    H_ham = zeros(1, Nw);
    w_ham = hamming(2*N+1)';
    
    h_ham = h.*w_ham;
    
    for k=1:Nw;
        H_rect(k) = sum(h.*exp(-j*w(k)*n));
        H_ham(k) = sum(h_ham.*exp(-j*w(k)*n));
    end
    H_rect = real(H_rect);
    H_ham = real(H_ham);
