Open this Example

Display Optimization Expression

Create an optimization variable, and create an expression.

x = optimvar('x',3,3);
A = magic(3);
expr = sum(sum(A.*x));

Display the expression.

showexpr(expr)
  8*x(1, 1) + 3*x(2, 1) + 4*x(3, 1) + x(1, 2) + 5*x(2, 2) + 9*x(3, 2)
+ 6*x(1, 3) + 7*x(2, 3) + 2*x(3, 3)