% EXAMPLE:  zero-padding for linear convolution via DFT

figure;
for N=8:2:24
    
    % Number of nonzero elements
    L = 8;

    % Domain 
    n = (0:N-1)';

    % Real signals (padded with zeros as required)
    x1 = [ones(L,1); zeros(N-L,1)];
    x2 = [ones(L,1); zeros(N-L,1)];

    % DFT of signals
    X1 = fft(x1);
    X2 = fft(x2);

    % Product of DFTs
    X = X1.*X2;

    % Circular convolution
    x = ifft(X);

    % Output
    subplot(3,1,1);  stem(n,x1);
    title(sprintf('N=%i, L=%i', N, L));
    subplot(3,1,2);  stem(n,x2);
    subplot(3,1,3);  stem(n,x);
    
    pause;
end