Question: mylinecheck(a,b,c,d,e,f) which takes six inputs: [30 pts] a,b,c,d,e,f: Real numbers. You may assume that a,c,e are all nonequal. Does: Checks if the three points (a, b), (c, d) and (e, f) all lie on the same line. How you do this is up to you but I suggest trying to find a really quick way. Quick ways exist! You’ll almost certainly need an if statement. Returns: 1 if they do and 0 if they don’t
Code:
if true % code
endfunction mylinecheck(a,b,c,d,e,f)p1 (a,b);p2 (c,d);p3 (e,f);endfunction tf = collinear2(p1,p2,p3)m = slope(p1,p2);b = intercept(p1,p2);if ~isfinite(m)if (p3(1)==p1(1))tf = true;elsetf = false;endelsetf = (m*p3(1)+b) == p3(2);endendfunction m = slope(p1,p2)m = (p2(2)-p1(2))/(p2(1)-p1(1));endfunction b = intercept(p1,p2)m = slope(p1,p2);b = -p1(2)+m*p1(1);endTest file:format long;a=mylinecheck(0,0,2,2,5,5)
Error: Error using mylinecheck Too many output arguments.
Error in Test (line 2) a=mylinecheck(0,0,2,2,5,5)
Best Answer