フィルターのクリア

I don't understand this command : F=find(B>4)

1 回表示 (過去 30 日間)
Roberta
Roberta 2023 年 5 月 16 日
コメント済み: Roberta 2023 年 5 月 17 日
If I have this matrix :
B=[1 2 3 4; 5 6 7 8], why when I run this -> F=find(B>4) , the result is:
2
4
6
8
?
Thank you

回答 (2 件)

Cris LaPierre
Cris LaPierre 2023 年 5 月 16 日
That looks correct. What is it you are expecting?
Since the output is returning a single index for each value found, it is uslng linear indexing. You can read more about that here: https://www.mathworks.com/help/matlab/math/array-indexing.html#MatrixIndexingExample-2
If you prefer row & column index, use the following syntax
You can read more about the find function here: https://www.mathworks.com/help/matlab/ref/find.html
  1 件のコメント
Roberta
Roberta 2023 年 5 月 17 日
Thank you (:

サインインしてコメントする。


Paul
Paul 2023 年 5 月 16 日
B is a 2D matrix.
B=[1 2 3 4; 5 6 7 8]
B = 2×4
1 2 3 4 5 6 7 8
This command finds the "linear indices" of the elements of B that satisfy the criteria
find(B>4)
ans = 4×1
2 4 6 8
The linear indices are the indices of B when it's viewed a s 1D vector formed by vertically concatenating its columns, which can be shown as
B(:)
ans = 8×1
1 5 2 6 3 7 4 8
The 2nd, 4th, 6th, and 8th elements of B(:) are the elements greater than 4
  1 件のコメント
Roberta
Roberta 2023 年 5 月 17 日
Thank you :-))

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by