% Studying convolution in dimension 1
%
% Samuli Siltanen November 2014

% Parameters for controlling the plot
fsize = 14;

% Create evaluation points 
Ny = 256;
y  = linspace(0,2*pi,Ny);

% Construct original signal f
f = MyFun1(y);

% Construct "point spread function"
% and normalize it so that its elements sum to 1
psf = [1 1 1];
psf = conv2(psf,psf);
psf = conv2(psf,psf);
psf = conv2(psf,psf);
psf = conv2(psf,psf);
psf = psf/sum(psf);

% Compute convolution
p_f = conv2(f,psf,'same');

% Take a look of the FFTs of f and p_f
Ff   = fft(f);
Fp_f = fft(p_f);

figure(3)
clf
% Plot the FFTs
plot(abs(fftshift(Ff)),'k')
hold on
plot(abs(fftshift(Fp_f)),'r')
title('FFT of signal f (black) and convolution p*f (red)','fontsize',fsize)
