%% Create Multidimensional Optimization Expressions
% Create an empty 3-by-4-by-2 array of optimization expressions.

expr = optimexpr(3,4,2)

%
% Create a 3-by-4 array of optimization expressions, where the first dimension is indexed by the strings "brass", "stainless", and "galvanized", and the second dimension is numerically indexed.

bnames = ["brass","stainless","galvanized"];
expr = optimexpr(bnames,4)

%
% Create an expression using a named index indicating that each stainless expression is 1.5 times the corresponding x(galvanized) value.

x = optimvar('x',bnames,4);
expr('stainless',:) = x('galvanized',:)*1.5;
show(expr('stainless',:))

% Copyright 2012 The MathWorks, Inc.