clear close all; x = linspace(-8,8,321); dx = x(2)-x(1); out = zeros(size(x)); k1 = find(x==-1.5); k2 = find(x==6.5); aviobj = avifile('convolve1.avi','compression','Cinepak'); for k=k1:k2, subplot(3,1,1); plot(x,f(x),'b',x,h(x(k)-x),'r','LineWidth',2); axis([-8 8 0 4]); subplot(3,1,2); g = f(x).*h(x(k)-x); plot(x,g,'k','LineWidth',2); axis([-8 8 0 4]); out(k)=sum(g)*dx; subplot(3,1,3); plot(x,out,'k','LineWidth',2); axis([-8 8 0 4]); frame=getframe(gcf); aviobj = addframe(aviobj,frame); end; aviobj = close(aviobj);
See video.