I am facing an issue with which data structure to use and when. My use case involves unique keys, each of which will be mapped to an array of values.
'UniqueKey1' -> ['Value1', 'Value2', 1, 2];
'UniqueKey2' -> ['Value2', 'Value3', 2, 5];
'UniqueKey3' -> ['Value3', 'Value4', 2, 5];
I know Struct could be one of the options, but I am worried about the performance when the data size is large (more than 100 rows). Can someone recommend a better alternative in my case?
dictionaryif your version of MATLAB is R2022b or newer. mathworks.com/help/matlab/dictionary.htmlstructis very efficient, even for hundreds or thousands of keys. Since you mention "rows", also take a look attable. It's less efficient for lookup thanstructordictionary, but it is very convenient overall.