Find specific coulum with condition in large matrix

2 次查看(过去 30 天)
Hellow
i would like to know the specific coulum or coulums in matrix that have two condtion in each row . these two number in each row should be in the same coulum on matrix
for example if i have this matrix
A =
1 2 3 4 5 6
7 8 9 10 11 12
if i want number in row 1 should be less than 4 and row 2 should be higher than 7
the results should have
B =
2 3
8 9
thank you for helping
  2 个评论
madhan ravi
madhan ravi 2021-1-31
编辑:madhan ravi 2021-1-31
What about 10, 11 and 12?
edit: Missed out the part "these two number in each row should be in the same coulum on matrix"
mohammed hussein
mohammed hussein 2021-2-1
thank you for answer , the first condition should be less than 4 so we cant take 10 ,11, and 12

请先登录,再进行评论。

采纳的回答

Cris LaPierre
Cris LaPierre 2021-1-31
A = [1 2 3 4 5 6
7 8 9 10 11 12];
B = A(:,A(1,:)<4 & A(2,:)>7)
B = 2×2
2 3 8 9

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by