Picking arrays from a matrix based on a condition

2 次查看(过去 30 天)
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