ENUMARRAY

Version 1.1.0.1 (4.34 KB) by Jen
An array that inherits from class DOUBLE and allows a user to index elements using an enumerated typ
931 Downloads
Updated 1 Sep 2016

View License

ENUMARRAY inherits from class double, but allows a user to index into the array using enumerated indices (i.e. strings) rather than numerical indices. Inputs are the array data, an MxNxPx... double array containing the data, and cell arrays of strings used to index into the data.
The created object can be referenced using strings or numeric indices.

Comments and reports of bugs are welcome.

Example:

data = repmat((1:10)',1,6) + repmat([10 20 30 40 50 60],10,1);

ind1 = {'one','two','three','four','five','six','seven','eight','nine','ten'};

ind2 = {'red','orange','yellow','green','blue','purple'};

EA = enumarray(data,ind1,ind2)

EA('one','red')

ans =

11

See the comments for more detailed examples. Note that due to the use of OOP, the earliest version of MATLAB for which this works is R2008a.

Cite As

Jen (2024). ENUMARRAY (https://www.mathworks.com/matlabcentral/fileexchange/21488-enumarray), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2008a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.1.0.1

Updated license

1.1.0.0

Add support for colon operator (:) and single column/row retrieval. (ie ds(:,'col1') )

1.0.0.0