index.m - create a list of the indices and values of an array

版本 1.1.0.0 (2.0 KB) 作者: Georg Stillfried
Create a list where each value (content) of an array is displayed together with its index.
1.1K 次下载
更新时间 2009/5/26

查看许可证

This function displays each value of an array together with its index. It is possible to ignore zeros and/or NaNs and/or to sort the list according to value. The values can be integers or floating point numbers.

EXAMPLES:

>> a=[2,3,NaN;1,2,4;7,0,9];

>> index(a,'sorted')

ans =
3 2 0
2 1 1
1 1 2
2 2 2
1 2 3
2 3 4
3 1 7
3 3 9
1 3 NaN

>> index(a,'sorted','nonans','nozeros')

ans =
2 1 1
1 1 2
2 2 2
1 2 3
2 3 4
3 1 7
3 3 9

引用格式

Georg Stillfried (2024). index.m - create a list of the indices and values of an array (https://www.mathworks.com/matlabcentral/fileexchange/21330-index-m-create-a-list-of-the-indices-and-values-of-an-array), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2007b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.1.0.0

faster through ind2sub

1.0.0.0

improved speed for large arrays