
nmax=20;
subplot(8,1,1:6)
set(gca,'nextplot','replacechildren');




subplot(8,1,8)

xlabel('n', 'fontsize', 16)

set(gca,'nextplot','replacechildren');
for n = 1:nmax
subplot(8,1,1:6)

bar(0:1:nmax,binopdf(0:1:nmax,n,0.4),1,'y' )
hold
axis([-0.5 20 0 0.8]);
plot(-0.5:0.1:20, normpdf(-0.5:0.1:20, n*0.4, sqrt(n*0.4*0.6)), 'LineWidth',2)
legend('Binomisk(n,p)', 'Normal(n*p, n*p*(1-p))')
xlabel('x', 'fontsize', 16)
ylabel('f(x)', 'fontsize', 16)
title('p=0.4')
hold
subplot(8,1,8)
plot(n,0.5,'*')
axis([0 nmax 0 1])

F3(n)=getframe(gcf);
end

h2=figure
movie(h2,F3,1,2)



movie2avi(F3,'binopoissfilm.avi','fps',2)