clear
clf
c1=[];
x1=[];
%z1=[];
global a b c
f=1;
for c= 2:.02:7 %varying c

a= 0.17930153;%initial conditions
b= 0.17930153;
%c=4.25;
%c=7;
x=0.1; %initial conditions
y=0.2;
z=0.3;

t=.01;
tMax = 50;
dt = .01;

tt  = t;

Y = [x;y;z];

x = Y(1);
y = Y(2);
z = Y(3);


%n=600;
%ni=88;
while (t<tMax) 
   
 ydot = ross_ode(t,Y);

    
    x = [x,Y(1)];
    y = [y,Y(2)];
    z = [z,Y(3)];
   
   f1 = ross_ode(t, Y);
   f2 = ross_ode(t+dt/2,Y+f1.*(dt./2));
   f3 = ross_ode(t+dt/2,Y+f2.*(dt./2));
   f4 = ross_ode(t+dt, Y+f3.*dt);
   
   Y = Y + (f1+f2.*2 + f3.*2 + f4).* (dt/6);
   
  
    tt   = [tt,t];
    
    t = t + dt;

    Y = Y + dt.*ydot;

%l=length(y);%length of y
%if sign(y(l)) ~= sign(y(l-1)) 
%x1=[x1,x(l)]; %stores x for plotting when y=0
%z1=[z1,z(l)];
%c1=[c1,c];%stores c for plotting
%end




end
%for ii=1:50 
%int=n-400;

plot3(x(2000:5000),y(2000:5000),z(2000:5000),'b')
xlabel('X')
ylabel('Y')
zlabel('Z')
title('Rossler Attractor with C varied')
axis([-14 10 -15 8 0 25])%sets axis dimensions
view([-46 48]);
pause(.01)

saveas(gcf, ['frame_',sprintf('%03d',f),'.png'])
f=f+1;
%plot3(x(int:n),y(int:n),z(int:n),'b') %plots snake with tail length of 1000
%axis([-10 10 -10 10 0 15])%sets axis dimensions
%pause(.01)

%n=n+ni;
%end
%f=f+50;

end

%end
%hold on
%plot(c1,x1,'s','MarkerSize',3,'MarkerFaceColor','b','MarkerEdgeColor','b')
%plot(c1(10000:26000),x1(10000:26000),'s','MarkerSize',3,'MarkerFaceColor','b','MarkerEdgeColor','b')

%plot(x1,z1,'*') %part 3 of hw, shows poincare sections 
%plot(x1(50:123),z1(50:123),'+')%poincare sections with early values
%filtered for cleaner graph
%plot(x,tt,'g') %answer for pt 1 a
%pause
%plot(x,y,'r')
%plot(x(10000:20000),y(10000:20000),'r') %answer for pt 1 b
%pause
%plot3(x,y,z,'b')



%end

%pause
%plot(z,tt)

%axis equal
%pause





