Borrar filtros
Borrar filtros

Slope of line intersecting with y axis

1 visualización (últimos 30 días)
LH
LH el 11 de Oct. de 2022
Editada: John D'Errico el 11 de Oct. de 2022
Hi,
I am trying to caluclate the slope of a line intersecting with one of the axes. I do understand that, as shown in the figure below, the slopw in case (a) is the where θ is the angle between the line and the x axis. But what about case (b)? What is the slope when the line intersects with the y axis and the angle θ becomes between the line and the y axis. is the slope becomes the ?
% case a
slope_a = tan(theta) % or y2-y1/x2-x1
%case b
slope_b = cot(theta) % or x2-x1/y2-y1
Thanks.

Respuestas (1)

John D'Errico
John D'Errico el 11 de Oct. de 2022
Editada: John D'Errico el 11 de Oct. de 2022
What has this to do with MATLAB?
The axis has NOTHING to do with the slope!!!!
The slope in both cases is (y2 - y1)/(x2 - x1). Which axis a line intersects is completely irrelevant. In fact, do you see the line ALWAYS intersects both axes, unless the line is exactly horizontal or vertical. In the case of a vertical line of course, the slope is undefined.
How you define the ANGLE a line intersects with an axis is irrelevant, as slope is not represented by an angle. Yes, you can compute that angle, but then surely you would recognize that the angle a line makes when it intersects with the two axes is always given by the angles of a right triangle, and therefore one angle is 90 degrees minus the other?

Categorías

Más información sobre Line Plots 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