%% Evaluate Optimization Expression At Point
% Create an optimization expression in two variables.

x = optimvar('x',3,2);
y = optimvar('y',1,2);
expr = sum(x,1) - 2*y;

%
% Evaluate the expression at a point.

xmat = [3,-1;
    0,1;
    2,6];
sol.x = xmat;
sol.y = [4,-3];
val = evaluate(expr,sol)

% Copyright 2012 The MathWorks, Inc.