%Script file to check the birds program numits=1000; numbirds=60; X=rand(numbirds,2); % X=[0 10 % 0 -10 % 10 0 %-10 0]; dX=randn(numbirds,2); Y=zeros(numits,numbirds,2); dY=zeros(numits,numbirds,2); Y(1,:,:)=X; dY(1,:,:)=dX; %t(1)=0.01; %Rate for dX / Change in velocity %t(2)=0.5; %Attraction rate / M1:Center of Mass of bird positions %t(3)=3.15; %Repelling rate / M2:Repelling rate from the closest bird %(4)=0.3; %Change in velocity / M3:Mean Velocity t(1)=.5+(.001*numbirds); %Rate for dX / Change in velocity t(2)=.21;%+(.001*numbirds); %Attraction rate / M1:Center of Mass of bird positions t(3)=.25;%+(.001*numbirds); %Repelling rate / M2:Repelling rate from the closest bird t(4)=.001; %Change in velocity / M3:Mean Velocity for i=2:numits [A,B]=birds(X,dX,t); if i<20 str='k*'; elseif i<30 str='b*'; elseif i<50 str='r*'; else str='mo'; end plot(A(:,1),A(:,2),str); axis([-30 30 -30 30]); if i==2 %hold on end %M(:,i-1)=getframe; pause(.2); Y(i,:,:)=A; dY(i,:,:)=B; X=A; dX=B; end %black=initial %blue=next %red=next next %magenta= next^3 %b1=squeeze(Y(:,1,:)); %b2=squeeze(Y(:,2,:)); %b3=squeeze(Y(:,3,:)); %plot(b1(:,1),b1(:,2),'r'); %hold on %plot(b2(:,1),b2(:,2),'b'); %plot(b3(:,1),b3(:,2),'m');