xvals=linspace(-4,4,41);
yvals=linspace(-4,4,41);
hold on;
for x=xvals
    for y=yvals
        slope=slopefield(x,y);
        angle=atan(slope);
        l=.15;
        x1=x-l/2*cos(angle);
        y1=y-l/2*sin(angle);
        x2=x+l/2*cos(angle);
        y2=y+l/2*sin(angle);
        plot([x1 x2],[y1 y2],'b');
    end
end
