How can I select a part of a matrix ?

3 ビュー (過去 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 Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by