Create Optimization Expressions Indexed by Strings
strexp = ["red","green","blue","yellow"]; expr = optimexpr(strexp)
expr = 1×4 OptimizationExpression array with properties: IndexNames: {{} {1×4 cell}} Variables: [1×1 struct] containing 0 OptimizationVariables See expression formulation with showexpr.
You can use a cell array of character vectors instead of strings to get the same effect.
strexp = {'red','green','blue','yellow'}; expr = optimexpr(strexp)
expr = 1×4 OptimizationExpression array with properties: IndexNames: {{} {1×4 cell}} Variables: [1×1 struct] containing 0 OptimizationVariables See expression formulation with showexpr.
If, instead, strexp is 4-by-1 instead of 1-by-4, then expr has that size as well:
strexp = ["red";"green";"blue";"yellow"]; expr = optimexpr(strexp)
expr = 4×1 OptimizationExpression array with properties: IndexNames: {{1×4 cell} {}} Variables: [1×1 struct] containing 0 OptimizationVariables See expression formulation with showexpr.