function Hw3

%% Section 2.2 Problem 30
Nx=30; Ny=30;
x_0=-1; x_1=1;
y_0=-1; y_1=1;

dx=(x_1-x_0)/Nx; 
dy=(y_1-y_0)/Ny; 

f=zeros(Nx,Ny,2);
x_axis=zeros(Nx,1);
y_axis=zeros(Ny,1);
for iy=1:Ny
    y=y_0+dy*(iy-1);
    y_axis(iy,1)=y;
    for ix=1:Nx
        x=x_0+dx*(ix-1);
        x_axis(ix,1)=x;
        f(ix,iy,1) = x-y;
        f(ix,iy,2) = y-4*x;
    end
end

clf
figure(1)
hold on
quiver(x_axis,y_axis,transpose(f(:,:,1)),transpose(f(:,:,2)),2)
axis([x_0 x_1 y_0 y_1])
print('SlopeFieldSec2pt2Prob30','-depsc',figure(1))
stop
