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

12 ビュー (過去 30 日間)
Yana Muhamadinah
Yana Muhamadinah 2019 年 7 月 26 日
コメント済み: Yana Muhamadinah 2019 年 8 月 1 日
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 Center および File Exchange2-D and 3-D Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by