One way to create a simple dictionary with an array as a value without using containers.map
in Matlab is to use a cell array to store the key-value pairs. Here's an example implementation:
main.m363 chars13 lines
In this implementation, dict
is a cell array where each row contains a key-value pair. The key is stored in the first column and the value is stored in the second column. To add a new key-value pair, we append a new row to dict
with the key in the first column and the value in the second column. To access the value for a given key, we use strcmp
to find the row corresponding to that key and then retrieve the value from the second column of that row.
gistlibby LogSnag