%Math 316 - Spring 2017
%Chapter 1 - Code 3
%Written by M. Motamed @ UNM 
%==============================================
%Direction field for the ODE: dv/dt = 9.8 - v/5
%==============================================

T=10;   %final time
[t,v] = meshgrid(0:1:T,-20:5:80);    

dt=ones(size(t));
dv=9.8-v/5;

figure
quiver(t,v,dt,dv)
xlabel('t')
ylabel('v')
set(gca,'fontsize', 20);
axis([0 T+1 -20 80])

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%A better way to plot direction field

L=sqrt(dt.^2 + dv.^2);

figure
hold on
quiver(t,v,dt./L,dv./L)
xlabel('t')
ylabel('v')
axis([0 T+5 -20 80])
set(gca,'fontsize', 20);
