How to use logical indexing to return parts of an array that matches the elements of another array?

2 views (last 30 days)
Tomaszzz
Tomaszzz on 25 Jan 2022
Commented: KSSV on 25 Jan 2022
Hi all,
I have two signals 'a" and 'b' (attached) collected at the same time (see figure below). I have identified certain events in signal ''a'' (attached "a_events_frames' and 'a_events_values'/ plotted over signal a in the figure). Now I want:
  • Return and save parts of the signal B that corresponds to parts in A between events 1-2, 2-3, 3-4, 4-5, 5-6, 6-7, 7-8
Can you help please?

Accepted Answer

KSSV
KSSV on 25 Jan 2022
Read about findpeaks. It will give you the indices and values of peaks; using the indices you can get yopur required values.
  4 Comments
KSSV
KSSV on 25 Jan 2022
b(a_indices)
The above line will give you values in b at the indices a_indices. It will not give you indices from b. Already you have indices a_indices.
If you know the indices of peaks 1,2,3,etc. You can get the values betweent he peaks using:
a(id1:id2) % id1 is index of peak1, id2 is index of peak 2
a(id2:id3) % id2 is index of peak2, id3 is index of peak 3

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!