% convolution example (discretized approximation of integral)

dt=0.001;
t=-pi:dt:pi;
f=1.0*(t>=0 & t<=1); % characteristic function on [0,1]

figure;
plot(t,f);
set(gca,'fontsize',20,'xlim',[-pi pi],'ylim',[-.1 1.1])
legend('f','f*f')

fstarf=conv(f,f,'same')/(2*pi)*dt; % convolution f*f

figure;
plot(t,fstarf);
set(gca,'fontsize',20,'xlim',[-pi pi])
legend('f*f')

