function result = slope(x1,y1,x2,y2) %slope calculate slope of a line given two points on that line % % consumes: x1, y1 the coordinates of the first point % x2, y2 the coordinates of the second point % % produces: result, the slope of the line % % % examples: % >> slope(1,1,9,5) % ans = % 0.5 % >> slope(0,-5,-5,5) % ans = % -2 % >> % P. Conrad for CISC106, Sect 99, 09/15/2007 result = (y2 - y1) / (x2 - x1); return; end