0

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?

2
  • 1
    Use dictionary if your version of MATLAB is R2022b or newer. mathworks.com/help/matlab/dictionary.html Commented May 22, 2024 at 20:20
  • By the way, struct is very efficient, even for hundreds or thousands of keys. Since you mention "rows", also take a look at table. It's less efficient for lookup than struct or dictionary, but it is very convenient overall. Commented May 22, 2024 at 20:24

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.