[x,y] = meshgrid(-2:0.25:2, -2:0.25:2); slope = x - y; % Vectors with components (1, slope) have the desired slope. z = ones( size(slope) ); % Normalize to make all mini-tangents have the same length. sx = z./(10*sqrt( z.^2 + slope.^2 )); sy = slope./(10*sqrt( z.^2 + slope.^2 )); % Plot mini-tangents... quiver(x,y,sx,sy,0,'ShowArrowHead','off') hold on % ... on both sides of grid points. quiver(x,y,-sx,-sy,0,'ShowArrowHead','off') % Add some solutions. x=-2:.01:2; for c=-1:3 y=x-1+c*exp(-x); plot(x,y,'linewidth',5) end axis([-2 2 -2 2]); title("Slope field for y'=x-y with five soln's");