Given two vectors p1 and p2, return the slope of a line that passes through p1 and p2.
Examples:
Input [p1,p2] = deal([0,1],[1,3])
Output m = 2
Input [p1,p2] = deal([-2,0],[0,1])
Output m = 0.5
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers52
Suggested Problems
-
Replace NaNs with the number that appears to its left in the row.
3060 Solvers
-
Back to basics 12 - Input Arguments
619 Solvers
-
542 Solvers
-
Change the sign of even index entries of the reversed vector
637 Solvers
-
540 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
P.S. This is supposed to be a beginner problem; there is no actual difficulty or challenge ?
Thanks for contributing a problem, Ashley. I think it's good to have problems that cover a range of difficulty so that players of all levels can engage with Cody. Your problem's description is clear and concise, and it has a decent number of tests: others recommend at least four tests to discourage lookup solutions.
One suggestion is to use the search tool to check whether others have written similar problems. In this case Cody Problem 43546 is similar. I wrote two problems that I later learned repeat existing problems. Now I check and change the idea if I find a similar existing problem.