MATLAB: Extract certain rows from matrix

data processing

Hello,
I have extracted the peak data from a 1×86400 matrix in the workspace (named a) using the following command:
[pks,locs]=findpeaks(a)
This results in 'pks' = 1×14382 and the 'locs' positions for the obtained data (Also sized at 1×14382).
I would like to use the locations (locs) from the above to extract data from another 1×86400 data file (in this case named b).
Whats the best approach to do this?

Best Answer

Assuming you read the other data file into another_matrix, the answer is
extracted_data = another_matrix(loc);
I suggest you read about Matrix indexing in MATLAB.