Using Maps
like in the example on MathWorks (see below) seem useful on first sight. But on second thought, they're a container structure, just as Matlab's struct
variable types. I'm new to Maps
and missing the advantage of when to use them as opposed to structs
- to break the question down into some measurable parameters: In what some use-cases is using Maps
vs structs
faster and uses less lines of code?
from MathWorks docs, example:
months = {'Jan','Feb','Mar','Apr'};
rainfall = [327.2 368.2 197.6 178.4];
M = containers.Map(months,rainfall)
vs something similar with structs
months = {'Jan','Feb','Mar','Apr'};
rainfall = [327.2 368.2 197.6 178.4];
for ind=1:numel(months)
s.(months{ind})=rainfall(ind);
end