1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

MATLABでargmax

Last updated at Posted at 2023-02-15

MATLABでargmax, argminをするときはmax, min関数を使う。

max, min

行列から最大値・最小値を取得する、いわゆるフツーのmax, min

>> values = [93, 47, 102, 39];

>> max(values)
ans = 102

>> min(values)
ans = 39

argmax, argmin

max, min関数で戻り値を2つ指定すると、1つ目の戻り値に最大値、2つ目の戻り値に最大値のインデックスが返される。

>> values = [93, 47, 102, 39];

>> [max_value, max_index] = max(values);
max_value = 102
max_index = 3

>> [min_value, min_index] = min(values);
min_value = 39
min_index = 4
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?