Find specific coulum with condition in large matrix

조회 수: 1 (최근 30일)
mohammed hussein
mohammed hussein 2021년 1월 31일
댓글: mohammed hussein 2021년 2월 1일
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
  댓글 수: 1
mohammed hussein
mohammed hussein 2021년 2월 1일
thank you very much for your answer , this exactly what i want

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

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