array2ind

A modification of the built-in sub2ind.

您现在正在关注此提交

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. 检索时间: .

类别

Help CenterMATLAB Answers 中查找有关 Matrices and Arrays 的更多信息

一般信息

MATLAB 版本兼容性

  • 兼容任何版本

平台兼容性

  • Windows
  • macOS
  • Linux
版本 已发布 发行说明 Action
1.0.0.0