Array with named indices
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
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.