% Matlab diary from cs110a, Mar 7 2005. % % This is what I typed in class. % % Type it into Matlab yourself to % reproduce the output I showed. f = @(t,y) -[2*y(1) ; y(2)/500] / norm([2*y(1) ; y(2)/500]) % The next line should have 0.01 instead of 0.1 , corrected later in class ode23(f, [0 10], [0.1 ; 10]) legend('y(1)= East', 'y(2) = West') legend('y(1)= East', 'y(2) = North') tspan = [0 10]; y0 = [0.1 ; 10] % should be 0.01 again [T,Y]=ode23(f,tspan,y0);steps=length(T),plot(Y(:,1),Y(:,2),'.');axis equal; shg plot(Y(:,2)) plot(Y(:,1)) plot(Y(:,1),'.') ode23(f, [0 10], [0.01 ; 10]) y0 = [0.01 ; 10] [T,Y]=ode23(f,tspan,y0);steps=length(T),plot(Y(:,1),Y(:,2),'.');axis equal; shg plot(Y(:,1),'.') plot(Y(:,1)) ode23s(f, [0 10], [0.01 ; 10]) [T,Y]=ode23s(f,tspan,y0);steps=length(T),plot(Y(:,1),Y(:,2),'.');axis equal; shg plot(Y(:,1))