How can I copy the value of points around the result of a specific function?

1 view (last 30 days)
How can I copy the value of points around the result of a specific function? E.g. Let us suppose I am using findpeaks to find the peaks of a given set of data, but I also want the code to copy the value of the point following the peak (the next one). Is there a way to do so?

Accepted Answer

YT
YT on 15 Dec 2017
I don't know if I understand the question correctly, but did you mean something like this (using findpeaks() as example)
data = rand([1 10]);
plot(data)
[pks,locs] = findpeaks(rand([1 10]));
disp('Current locations / values:');[locs;pks]
%Current locations / values:
%ans =
%
% 4.0000 7.0000
% 0.3520 0.7838
disp('Next locations / values (+1)');[(locs+1);data(locs+1)]
%Next locations / values (+1)
%ans =
%
% 5.0000 8.0000
% 0.1528 0.0175
  2 Comments
Shitake Silva
Shitake Silva on 16 Dec 2017
That's exactly what I wanted. The problem is, I wasn't keeping track of the location of the points. I was using something like: X = findpeaks(rand([1 10])); Which gives me just the values.
Problem solved! Thanks a lot!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!