Create Multidimensional Optimization Variables
Create a 3-by-4-by-2 array of optimization variables named xarray.
xarray = optimvar('xarray',3,4,2)
xarray = 3×4×2 OptimizationVariable array with properties: Array-wide properties: Name: 'xarray' Type: 'continuous' IsSubset: 0 IndexNames: {{} {} {}} Elementwise properties: LowerBound: [3×4×2 double] UpperBound: [3×4×2 double] See variables with showvar. See bounds with showbounds.
You can also create multidimensional variables indexed by a mixture of names and numeric indices. For example, create a 3-by-4 array of optimization variables where the first dimension is indexed by the strings 'brass', 'stainless', and 'galvanized', and the second dimension is numerically indexed.
bnames = ["brass","stainless","galvanized"]; bolts = optimvar('bolts',bnames,4)
bolts = 3×4 OptimizationVariable array with properties: Array-wide properties: Name: 'bolts' Type: 'continuous' IsSubset: 0 IndexNames: {{1×3 cell} {}} Elementwise properties: LowerBound: [3×4 double] UpperBound: [3×4 double] See variables with showvar. See bounds with showbounds.