Array with named indices

Version 1.2.0.0 (2.66 KB) by Ofer S
manipulate multi-dimensional arrays by referring to their indices.
37 Downloads
Updated 26 Jul 2016

View License

When working with multi-dimensional arrays it is sometimes more convenient to perform operations by explicitly specifying the indices. iArray is a class that provides an interface for multiplying,adding,summing over,etc. for multi-dimensional numerical arrays.
Using iArray it is straightforward to implement such mathematical expressions (see the snapshot image for example)
example:
A = iArray( rand(10000,20) , {'i' , 'k'} ) ;

creates a 10000x20 array with indices called 'i' and 'k' . the indices can be renamed at any time using curly braces , e.g. A = A{'i','m'}

B = iArray( rand(10000,20) , {'i' , 'm'} ) ;
w = iArray( rand(10000,1) , {'i'} ) ;

C = sum( w.*A.*B , 'i' );

or equivalently

C = sum( w{'i'}.*A{'i','k'}.*B{'i','m'} , 'i' ) ;

evaluates the expression in the screenshot.
the result C is an 20x20 iArray with indices 'k' and 'm'.

Cite As

Ofer S (2024). Array with named indices (https://www.mathworks.com/matlabcentral/fileexchange/58373-array-with-named-indices), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Matrix Indexing in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.2.0.0

extended description

1.1.0.0

image added

1.0.0.0