% Quiver plots for differential equations
% Displays direction fiels with arrows of unit length

figure(1)
[x,y]=meshgrid(-5:.5:5,-5:.5:5);
dx=y;
dy=-x;
dxu=dx./sqrt(dx.^2+dy.^2);
dyu=dy./sqrt(dx.^2+dy.^2);
quiver(x,y,dxu,dyu)
axis square
hold on

% Particular Solution
dz = @(t,z)[z(2); -z(1)];
ic = [0; 1];
tspan = [0 10];
[t,Z] = ode23(dz, tspan, ic);
plot(Z(:,1),Z(:,2),'r')
hold off

% Position vs Time
figure(2)
plot(t,Z(:,1)), title('Position vs. Time')
