Find first row with certain value in x2 array

3 次查看(过去 30 天)
I have an 300x2 array in which I need to find a certain numbert in colum 1, e.g. 10. Once the number is found I need to extract the corresponding value in colum 2.

采纳的回答

Chunru
Chunru 2021-6-8
idx = A(:, 1) == 10; % find the index that 1st column = 10
b = A(idx, 2); % extract the corresponding data in 2nd column
Or in one line
b = A(A(:,1)==10, 2);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by