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

1 次查看(过去 30 天)
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!

回答(1 个)

David Wilson
David Wilson 2019-7-26
编辑:David Wilson 2019-7-26
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

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by