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

2 Ansichten (letzte 30 Tage)
Yana Muhamadinah
Yana Muhamadinah am 26 Jul. 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!

Antworten (1)

David Wilson
David Wilson am 26 Jul. 2019
Bearbeitet: David Wilson am 26 Jul. 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

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by