필터 지우기
필터 지우기

How to return the rows with specific value?

조회 수: 3 (최근 30일)
Ahmed Hamed
Ahmed Hamed 2016년 4월 30일
답변: Azzi Abdelmalek 2016년 4월 30일
I have a simple matrix
X =
0 1 2
1 1 2
2 2.5 4.5
3 2 2
4 4 1.5
5 4 2.5
and another matrix
out = [3;4]
I'd like to return the rows in X whose rows start with any value in out
The output should look like
3 2 2
4 4 1.5
I tried this code
xx= X(X(:,1)==any(out),:)
but this always return the first row.
Any suggestion please Thanks in advance

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 30일
Y=X(ismember(X(:,1),out),:)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by