Matrix Arguments

Solvers accept matrix initial point x0, where matrix means an array of any size. They also accept matrix bounds lb and ub. Here's how solvers handle matrix arguments.

  • Internally, solvers convert matrix arguments into vectors before processing. For example, x0 becomes x0(:). For an explanation of this syntax, see the A(:) entry in colon.

  • For output, solvers reshape the solution x to the same size as the input x0.

  • When x0 is a matrix, solvers pass x as 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 vector form, x(:). In other words, a linear constraint of the form

    A*x ≤ b or Aeq*x = beq

    takes x as a vector, not a matrix. Ensure that your matrix A or Aeq has the same number of columns as x0 has elements, or the solver will error.

Was this topic helpful?