Find the slope of a line that passes through two vectors - MATLAB Cody - MATLAB Central

Problem 54665. Find the slope of a line that passes through two vectors

Difficulty:Rate
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

65.56% Correct | 34.44% Incorrect
Last Solution submitted on Dec 09, 2024

Problem Comments

Solution Comments

Show comments
Join Cody Contest 2025 — Have Fun and Win Prizes!
...
We’re excited to invite you to Cody Contest 2025! 🎉 Pick a team,...
Dive Into Hands-On Learning at MATLAB EXPO 2025 – Register Now!
Get ready to roll up your sleeves at MATLAB EXPO 2025 –...
0

Problem Recent Solvers52

Suggested Problems

More from this Author1

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!