Toolbox™ solvers accept vectors for many arguments, such as the initial point
x0, lower bounds
lb, and upper bounds
ub. They also accept matrices for these arguments, where matrix
means an array of any size. When your solver arguments are naturally arrays, not
vectors, feel free to provide the arguments as arrays.
Here is how solvers handle matrix arguments.
Internally, solvers convert matrix arguments into vectors before processing.
x0(:). For an
explanation of this syntax, see the
A(:) entry in
colon, or the "Indexing with a
Single Index" section of Array Indexing (MATLAB).
For output, solvers reshape the solution
the same size as the input
x0 is a matrix, solvers pass
a matrix of the same size as
x0 to both the objective
function and to any nonlinear constraint function.
Linear Constraints, though, take
x(:). In other words, a linear constraint of the
A*x ≤ b or
x as a vector, not a matrix. Ensure that your matrix
Aeq has the same number of
x0 has elements, or the solver will error.