필터 지우기
필터 지우기

Picking arrays from a matrix based on a condition

조회 수: 3 (최근 30일)
Fayyaz
Fayyaz 2018년 10월 22일
댓글: Fayyaz 2018년 10월 22일
Hi,
I have a matrix:
3 3 3 3 3 2 2 2 4 4
4 4 4 4 4 2 2 4 4 4
5 5 5 5 5 2 2 4 4 4
6 6 6 6 6 2 2 2 4 4
Suppose the first five elements in any row are represented by A (e.g., always the same value. for instance 3 in the first row) while the last five elements always include only two numbers i.e. B (equal to 2, in the first row) and C (equal to 4, in the first row)
How would I be able to pick those rows that hold: B<A<C. For instance, the below rows in the above case:
3 3 3 3 3 2 2 4 4 4
4 4 4 4 4 2 2 4 4 4
Many thanks.

채택된 답변

Bruno Luong
Bruno Luong 2018년 10월 22일
M=[3 3 3 3 3 2 2 2 4 4;
4 4 4 4 4 2 2 4 4 4;
5 5 5 5 5 2 2 4 4 4;
6 6 6 6 6 2 2 2 4 4]
[A,B,C]=deal(M(:,1),M(:,6),M(:,9));
M(B<=A & A<=C,:) % Not same criteria stated in your question
Gives:
ans =
3 3 3 3 3 2 2 2 4 4
4 4 4 4 4 2 2 4 4 4

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by