clear N=7; options=odeset('Reltol',1e-6,'OutputFcn','odeplot','OutputSel',[1,N]); t1=500; dt=0.5; for S=1:N, Y(S)=-1.5*pi*sin(pi*S/(2*N)); Y(S+N)=0; end [t,Y]=ode45('pendulatestani1',[0:dt:t1],Y,options,N); for cc=1:N, FL(cc)=0; JJ(cc)=(cc); %JJ(NN+2)=(NN+1)/sqrt(10); for H=1:(t1/dt), hh(H)=H*dt; YY(H,cc)=Y(H,cc); end end n=1; fig=figure; set(fig,'DoubleBuffer','on'); set(gca,'NextPlot','replace','Visible','off'); iname=sprintf('mov00v0.avi',1) mov = avifile(iname,'fps',20); for count=1:300, h = plot(YY(count,:),'ro-'); shading flat; axis([0 N+1 -8 8]) grid off set(h,'EraseMode','xor'); F = getframe(gca); mov = addframe(mov,F); clear F; clear h; end mov = close(mov); clear mov;