![test.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/231432/test.png)
how can i calculate the angle of each gradient and x axis?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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!
0 Commenti
Risposte (1)
David Wilson
il 26 Lug 2019
Modificato: David Wilson
il 26 Lug 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](https://www.mathworks.com/matlabcentral/answers/uploaded_files/231432/test.png)
Vedere anche
Categorie
Scopri di più su Line Plots in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!