필터 지우기
필터 지우기

Find first row with certain value in x2 array

조회 수: 3 (최근 30일)
Gevin Schaeffer
Gevin Schaeffer 2021년 6월 7일
댓글: Gevin Schaeffer 2021년 6월 8일
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);
  댓글 수: 1
Gevin Schaeffer
Gevin Schaeffer 2021년 6월 8일
Thanks :) ! it is really that simple. I literally just started with MATLAB

댓글을 달려면 로그인하십시오.

추가 답변 (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