Extended array indexing

版本 1.3.0.0 (4.4 KB) 作者: David Young
Indexes a virtual array formed by extending an array indefinitely on each dimension.
673.0 次下载
更新时间 2010/4/8

查看许可证

Given an array, it is possible to imagine a virtual array formed by padding the original array out in all directions. Valid subscripts for this virtual array range through all the negative and positive integers, without regard to the size of the original. This function implements this idea.

The padding out can be done in many ways. The following are implemented: using a constant value; replicating the border elements of the original; tiling the virtual array with copies of the original; tiling the virtual array with copies that have been flipped so that there is mirror symmetry along the borders of every copy. A different rule may be specified for each dimension.

The function is related to padarray, repmat and circshift, and padarray's option strings have been retained for consistency. However, exindex is more flexible than any of these; for example, the array can be cropped as well as extended, and indeed arbitrary indexing into the virtual array is allowed.

The function is easy to use:

exindex(arr, s1, s2, ...)

is equivalent to v(s1, s2, ...) where v stands for the virtual extended array. If one rule is to apply to all dimensions it can be specified with

exindex(arr, s1, s2, ..., rule)

or if different rules apply to different dimensions they can be specified with

exindex(arr, s1, r2, s2, r2, ...)

引用格式

David Young (2024). Extended array indexing (https://www.mathworks.com/matlabcentral/fileexchange/27117-extended-array-indexing), MATLAB Central File Exchange. 检索时间: .

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

Community Treasure Hunt

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

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

Padding constants must now always be enclosed in a cell. The input array may be of any class. Trailing singleton dimensions may be indexed (so e.g. a 2D array can be extended into 3D). The code has been tidied and the help comments extended.

1.0.0.0