Finding cosine of angle formed by two adjacent points of a curve and horizontal line
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Vahid Esmaeili
el 21 de Jul. de 2020
Comentada: Vahid Esmaeili
el 24 de Jul. de 2020
Hello,
I am wondering how to calculate the cosine of the angle formed by two very close points and the horizontal line in MATLAB? I want to find the cosine between every pair of adjacent points in a matrix. Please find a matrix ( of 1761 rows and 1 column in the attached EXCEL file).
Thank you so much,
0 comentarios
Respuesta aceptada
Kiran Felix Robert
el 24 de Jul. de 2020
Hi Vahid,
It is my understanding that you attempt to find the angle between the line formed by joining two adjacent points and the x-axis. Also use that to find angle between lines formed by every pair of adjacent points. The angle with the x-axis or the horizontal can be calculated as shown below, assuming B is the input Vector,
angle = zeros(length(B)-1,1); % Pre-allocating angles vector
for i = 1:(length(B)-1)
x = [i i+1];
y = [B(i) B(i+1)];
slope = (y(2) - y(1))/(x(2)-x(1));
angle(i) = atand(slope); % Angle in degrees
end
Angle between the lines can be calculated by simply subtracting the values in the angle vector.
angle1 = angle(2) - angle(1);
Thanks
Kiran
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical 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!