showexpr

Display optimization expression

Syntax

showexpr(expr)

Description

example

showexpr(expr) displays the optimization expression expr at the MATLAB® Command Window.

Examples

collapse all

Create an optimization variable and 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)

Input Arguments

collapse all

Optimization expression, specified as an OptimizationExpression object.

Example: sum(sum(x))

Tips

  • For an expression that has many terms, use writeexpr to generate a text file containing the expression information.

Introduced in R2017b