x = linspace(-2,2,321); dx = x(2)-x(1); out = zeros(size(x)); k1 = find(x==-1.25); k2 = find(x==1.25); % Default is Indeo, which is not included in Vista aviobj = avifile('convolve2.avi','compression','Cinepak'); for k=k1:k2, subplot(3,1,1); plot(x,rect(x),'b',x,rect(x(k)-x),'r','LineWidth',1.5); axis([-2 2 0 2]); subplot(3,1,2); g = rect(x).*rect(x(k)-x); plot(x,g,'k','LineWidth',1.5); axis([-2 2 0 2]); out(k)=sum(g)*dx; subplot(3,1,3); plot(x,out,'k','LineWidth',1.5); axis([-2 2 0 2]); frame=getframe(gcf); aviobj = addframe(aviobj,frame); end; aviobj = close(aviobj);
See video.