# calculation of slopes of 2 lines

3 visualizaciones (últimos 30 días)
krishnasri el 29 de Abr. de 2015
Editada: Roger Stafford el 1 de Mayo de 2015
I have end points of two lines, I want to find out the slope of these two lines. how can I find it out? after finding out the slope i need to find the angle between these 2 lines, can u help me with the code?
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (2)

Pratik Bajaria el 29 de Abr. de 2015
Hello,
your solutions is pretty clear. I presume, that you have X,Y cords. Once, you have them, its a cakewalk. Slope of a line is given by: m=(y2-y1)/(x2-x1) i.e. dy/dx, where point1 cordinates = (x1,y1) & point2 cordinates = (x2,y2).
Now in order to get the angle, just do an arctangent of the slope. Angle = arctan(m), where m is slope from above.
Just implement these mathematical formulas in MATLAB and its done.
Hope it helps. Regards, Pratik
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Roger Stafford el 1 de Mayo de 2015
Editada: Roger Stafford el 1 de Mayo de 2015
If your lines are three-dimensional, the concept of "slope" loses its significance. To find the angle between the lines, you can either use 'acos' or 'atan2'. I would recommend the latter.
If P1 and P2 are points on the first line, and Q1 and Q2 points on the second line,
D1 = P2-P1; D2 = Q2-Q1;
a = atan2(abs(cross(D1,D2)),dot(D1,D2));
Note: a will be in radians.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by