how can i calculate the angle of each gradient and x axis?

2 visualizaciones (últimos 30 días)
Yana Muhamadinah
Yana Muhamadinah el 26 de Jul. de 2019
Comentada: Yana Muhamadinah el 1 de Ag. de 2019
i have a line, its a sigmoid function. the code is like this
x = 0:0.1:10;
y = sigmf(x,[2 4]);
plot(x,y)
xlabel('sigmf, P = [2 4]')
ylim([-0.05 1.05])
i want to know every angle between each pair of point and the x axis. i mean for line y of x=0 and x=0.1, the angle is..
for line y of x=0.1 and x=0.2 the angle is...
how can i calculate that? thank you before!

Respuestas (1)

David Wilson
David Wilson el 26 de Jul. de 2019
Editada: David Wilson el 26 de Jul. de 2019
You could always differentiate to get the slope and then take the arc-tan.
syms x real
s = 1/(1 + exp(-2*(x-4)))
dsdx = diff(s,x) % lazy way to get derivative
slope = matlabFunction(dsdx)
x = [0:0.1:10]';
y = sigmf(x,[2 4]);
Angle = atan2d(slope(x),1) % note degrees
subplot(2,1,1);
plot(x,y,'o-')
subplot(2,1,2);
plot(x, Angle); ylabel('angle [deg]')
test.png

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by