Is there any concept like dictionary or hash tables in matlab like in Python?
606 views (last 30 days)
More Answers (4)
Mike Croucher on 15 Sep 2022
Vikram Raghu on 4 Apr 2019
Bill Tubbs on 17 Apr 2020
Edited: Bill Tubbs on 17 Apr 2020
struct seems to produce a much nicer text output than container.Map:
% Example with struct
settings = struct();
settings.open_loop = false;
settings.adaptive = true;
settings.estimator = 'RLSFF';
struct with fields:
% Example with Map
settings2 = containers.Map;
settings2('open_loop') = false;
settings2('adaptive') = true;
settings2('estimator') = 'RLSFF';
Map with properties:
Although they look identical when returning at the command line.
But is there a literal representation for a struct? So you can define it in code more concisely, something like this:
settings = struct(
(The above is not valid of course). Or is there some other way of doing this in a readable convenient way?