That completely depends on how you define ‘angle’.
This calculates the angle based on the peaks, and draws quiver arrows (‘angrad’ are the angles in radians):
angrad = atan2(pks,locs);
figure
hold on
plot(Y)
plot(locs, pks,"rx")
quiver(locs,pks,cos(angrad),sin(angrad), 0.25)
hold off
this calculates and draws arrows between adjacent peaks:
angrad = atan2(diff(pks),diff(locs));
figure
hold on
plot(Y)
plot(locs, pks,"rx")
quiver(locs(1:end-1),pks(1:end-1),cos(angrad),sin(angrad), 0.25)
hold off
There are likely several other ways as well.
This should get you started.
EDIT — (2 Oct 2020 at 12:31)
Corrected typographical error.
.
Best Answer