ENUMARRAY

Versione 1.1.0.1 (4,34 KB) da Jen
An array that inherits from class DOUBLE and allows a user to index elements using an enumerated typ
931 download
Aggiornato 1 set 2016

Visualizza la licenza

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.

Cita come

Jen (2025). ENUMARRAY (https://it.mathworks.com/matlabcentral/fileexchange/21488-enumarray), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2008a
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Versione Pubblicato Note della release
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