%% Call Python eval Function
% This example shows how to evaluate the expression x+y in Python®. To evaluate an expression, pass a Python dict value for the globals namespace parameter.
% Read the help for eval.

py.help('eval')

%
% Create a Python dict variable for the x and y values.

workspace = py.dict(pyargs('x',1,'y',6))

%
% Evaluate the expression.

res = py.eval('x+y',workspace)

%
% Add two numbers without assigning variables. Pass an empty dict value for the globals parameter.

res = py.eval('1+6',py.dict)

%
% Copyright 2012 The MathWorks, Inc.