Retrieving an array of values for an array of keys from a containers.map object
3 views (last 30 days)
Show older comments
My code uses a containers.map object smap. I currently have the following inside a loop with over 6 million iterations:
val(i) = smap(key(i))
I'd like to take it out of the loop to make it faster - I can make a cell array of the (string) keys called keyList, and I tried
val_arr = cellfun(@(x), smap(x), keyList, 'UniformOutput', 'false')
which works but is actually a few seconds slower than just calling it inside the loop. Can you suggest how I might do this faster?
0 Comments
Answers (1)
Walter Roberson
on 28 Sep 2011
val_arr = cellfun(@(x), smap(x), keyList, 'UniformOutput', 'false')
is a syntax error, as it has no function body for the anonymous function.
If you remove the comma after @(x) then it becomes valid.
See Also
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!