0001 x=linspace(0,2,1e3); 0002 f=(x<=1).*cos(0.6*pi*x); 0003 g=f+(x>1).*cos(0.6*pi*(x-1)); 0004 0005 k=exp(-(x-1).^2/2/0.03^2); 0006 0007 0008 subplot(4,1,1); 0009 plot(x,f); 0010 hold on 0011 plot(x,g,'r'); 0012 subplot(4,1,2); 0013 plot(x,k); 0014 subplot(4,1,3); 0015 0016 cf=fftshift(ifft(fft(fftshift(f)).*fft(fftshift(k)))); 0017 cg=fftshift(ifft(fft(fftshift(g)).*fft(fftshift(k)))); 0018 plot(x,cf); 0019 hold on; 0020 plot(x,cg,'r'); 0021 0022 subplot(4,1,4); 0023 plot(x,cf-cg); 0024 axis([0 2 -1e-13 1e-13]);