Here's an example of how to create a dictionary without containers.map in MATLAB using a loop with a double key and a cell array value:
main.m389 chars19 lines
In this example, we first define the range of double keys we want to use in the loop. Then, we create an empty dictionary using a struct()
function, which returns an empty structure with no fields.
Inside the loop, we create a random cell array for the value, with a length between 1 and 5. Then, we assign each element in the cell array a random integer between 1 and 10.
Finally, we add the key-value pair to the dictionary using the key i
and the value value
. Note that the double key is automatically converted to a string key in the dictionary.
gistlibby LogSnag