필터 지우기
필터 지우기

How can I select a part of a matrix ?

조회 수: 5 (최근 30일)
재훈
재훈 2022년 11월 24일
댓글: Image Analyst 2022년 11월 24일
I want to select the component of this matrix, whose first column value is bigger than 4, and the second column value is smaller than 0.6
B =
1.0000 0.3000
2.0000 0.6000
3.0000 0.5000
4.0000 0.7000
5.0000 0.2000
6.0000 0.5000
7.0000 0.4000
8.0000 0.5000
The code below is mine, but it never works,:( please help me.
Chosen_data=[];
for i=1:8;
Chosen_data=B((B(i,1)>4)&(B(i,2)<0.6));
end

채택된 답변

Voss
Voss 2022년 11월 24일
편집: Voss 2022년 11월 24일
B = [1 0.3
2 0.6
3 0.5
4 0.7
5 0.2
6 0.5
7 0.4
8 0.5];
idx = B(:,1) > 4 & B(:,2) < 0.6;
Chosen_data = B(idx,:)
Chosen_data = 4×2
5.0000 0.2000 6.0000 0.5000 7.0000 0.4000 8.0000 0.5000
  댓글 수: 2
재훈
재훈 2022년 11월 24일
Thank you ;)
Image Analyst
Image Analyst 2022년 11월 24일
@재훈 If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.

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

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