matthiasm@8: function val = subsref(A, S) matthiasm@8: % SUBSREF Subscript reference for an associative array matthiasm@8: % A('foo') will return the value associated with foo. matthiasm@8: % If there are multiple identicaly keys, the first match is returned. matthiasm@8: % Currently the search is sequential. matthiasm@8: matthiasm@8: i = 1; matthiasm@8: while i <= length(A.keys) matthiasm@8: if strcmp(S.subs{1}, A.keys{i}) matthiasm@8: val = A.vals{i}; matthiasm@8: return; matthiasm@8: end matthiasm@8: i = i + 1; matthiasm@8: end matthiasm@8: error(['can''t find ' S.subs{1}])