array2ind

版本 1.0.0.0 (1.5 KB) 作者: Greggory
A modification of the built-in sub2ind.
208.0 次下载
更新时间 2011/8/25

查看许可证

Usage:

ind = array2ind(SIZE, COORDINATES_AS_ARRAY)

Example:

g = magic(5);
ind = array2ind([5 5], [3 2])
g(ind)

returns the same value as if you had called

g(3,2)

Useful for when the coordinates for a matrix element are stored as an array and avoids the current method of:

b = [3 2];
g(b(1), b(2))

While this is suitable for some cases, it's not generalized or adaptable to changing sizes of b and g.

引用格式

Greggory (2026). array2ind (https://ww2.mathworks.cn/matlabcentral/fileexchange/32682-array2ind), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2011a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Matrices and Arrays 的更多信息
版本 已发布 发行说明
1.0.0.0