%% Index into Python dict
% This example shows how to get and set values in a dictionary.
% Create a dictionary variable in MATLAB®.

customers = py.dict

%
% Populate the dict variable with customer names and account numbers and display the results. The output depends on your Python® version.

customers{'Smith'} = int32(2112);
customers{'Anderson'} = int32(3010);
customers{'Audrey'} = int32(4444);
customers{'Megan'} = int32(5000);
customers

%
% Read the account number for customer Anderson.

acct = customers{'Anderson'}

%
% Convert to a MATLAB variable.

C = struct(customers)
acct = C.Anderson

%
%
% Copyright 2012 The MathWorks, Inc.