Say I used the "findpeaks" function to find the local maximas in my data as follows which produces the following graph:
t = 0:0.05:25; % values for time
y = cos(3*t);[pks,locs] = findpeaks(y);plot(t,y,t(locs),pks,'rv','MarkerFaceColor','r'); grid on; title('Position -vs- Time'); xlabel('Time'); ylabel('Position');
Obviously in this instance, all the local maximas would have the same values for position. However, for the sake of argument, say I only wanted to find the values for the position of the local maximas between time = 10 and time = 25, how would I go about doing this without changing the values for 't' which I initially used to plot the graph?
Any help appreciated!
Best Answer