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

6 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

Matt J
Matt J am 20 Mär. 2022
Bearbeitet: Matt J am 20 Mär. 2022
[elements,row]=unique(data(:,13))
element_timestamps=data(row,1)

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by