How to find the corresponding value of an element in same row, but different column?

4 views (last 30 days)
Hi everyone,
Perhaps a silly question, but:
I have several matrices that are approx. 1500-2000 rows and 13 columns each (corresponding to single-trial data, so one matrix per trial; from deeplabcut if anyone is familiar). I have a for-loop that uses the find function to find a specific element in column #13 for each matrix and lists them in a single column (so if I have 50 trials, I would then have a column of 50 numbers). I now simply want to find the corresponding element in column #1 (from the same row!) for each trial and generate another such list. Column #1 contains timestamp information, so I'm looking for the timestamp corresponding to the element found in column #13.
Here is some dummy code so far (this is after narrowing the data down to a specific range):
element_list = find(data(:,13);
element_I_want = element_list(1)
element_timestamp = ????
Thank you!!! I've tried a few things but keep getting errors. I'm sure I'm just missing something simple.

Accepted Answer

Matt J
Matt J on 20 Mar 2022
Edited: Matt J on 20 Mar 2022
[elements,row]=unique(data(:,13))
element_timestamps=data(row,1)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!