Why return function min in matlab return two values?

Hi guys !
Im using min function that's already built in matlab over an integer array like arr1=[1 2 3 4 5 6 7];
my problem is that min() returns two values(it's really weird !), first value if the min value of the array values, the other value I don't know what it's any help?
for instance:
[x y]=min(arr1) %arr1 is integer values
[x z]=min(arr2) %arr2 is integer values
[x m]=min(arr3) %arr3 is integer values
I get:
y= 1 , z=2 , m=1 .
the value x is the minmum value of the array.
so the second value that min return is 1 or 2 ..so what's this value about? could anyone please help me what this second value that min return is?
thanks alot!

4 件のコメント

Paras Patel
Paras Patel 2021 年 1 月 4 日
The 2nd value is the index number within the array where the min value is. From the help:
[M,I] = min(X) also returns the indices into operating dimension
corresponding to the minimum values. If X contains more than one
element with the minimum value, then the index of the first one
is returned.
Jimmy cho
Jimmy cho 2021 年 1 月 4 日
Appreciated !
Matt J
Matt J 2021 年 1 月 4 日
first value if the min value of the array values, the other value I don't know what it's any help?
If so, why haven't you googled the documentation?
Cris LaPierre
Cris LaPierre 2021 年 1 月 4 日
Paras, you should post your answer in an Answer field rather than a comment.

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

 採用された回答

Paras Patel
Paras Patel 2021 年 3 月 18 日

0 投票

The 2nd value is the index number within the array where the min value is. From the help:
[M,I] = min(X) also returns the indices into operating dimension
corresponding to the minimum values. If X contains more than one
element with the minimum value, then the index of the first one
is returned.

その他の回答 (0 件)

カテゴリ

質問済み:

2021 年 1 月 4 日

回答済み:

2021 年 3 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by