フィルターのクリア

How to find an array in a vector or matrix?

11 ビュー (過去 30 日間)
Ehsan Ben
Ehsan Ben 2021 年 4 月 14 日
回答済み: Ahmed Redissi 2021 年 4 月 14 日
I want to find a specific number in a vector, and I am using the following command
[s,t] = find(q_p_d100==qp100max)
But I get the follwoing:
s =
0×1 empty double column vector
t =
0×1 empty double column vector
However, I simply need a raw and column number of the position of the number I'm looking for.
('qp100max' is the maximum number in 'q_p_d100 vector')

採用された回答

Jan
Jan 2021 年 4 月 14 日
編集済み: Jan 2021 年 4 月 14 日
The output of FIND shows you, that qp100max is not the maximum value of q_p_d100, but it is not even an element of the vector:
any(q_p_d100 == qp100max) % FALSE
I assume, this is a rounding problem. Try it:
max(q_p_d100) - qp100max
Is this a small value?
To get the position of the maximum value:
[maxV, index] = max(q_p_d100)
If the value is not unique:
allIndex = find(q_p_d100 == maxV)

その他の回答 (1 件)

Ahmed Redissi
Ahmed Redissi 2021 年 4 月 14 日
You can use the function "ismember" to find if an array or a scalar is part of another array. Here is the documentation for it so you can learn how to use it:

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by