Find position of numbers in array
3 ビュー (過去 30 日間)
古いコメントを表示
Hi,
so i have an array W = [11, 56, 22, 45, 29]
then i use Z = mink(W,2) to find the 2 lowest numbers in W
how do i output the position of the numbers found in Z from the array W?
I tried find(Z) but i got the positions of the numbers in array Z, not their position in array W
For this exemple i used small numbers but the actual W has more then 200 numbers so typing a code for each would take forever
0 件のコメント
回答 (1 件)
DGM
2022 年 2 月 7 日
編集済み: DGM
2022 年 2 月 7 日
You can specify a second output argument to get the linear index of the elements represented by Z:
W = [11, 56, 22, 45, 29]
[Z idx] = mink(W,2)
2 件のコメント
DGM
2022 年 2 月 7 日
If you find that the answer has sufficiently satisfied the question, you can accept the answer. This moves it to the 'accepted' queue, where it may be more visible to the next person looking for help with the same problem.
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!