show

语法

``show(obj)``

说明

``show(obj)` 在命令行显示有关 `obj` 的信息。如果对象显示较大，请考虑改用 `write` 以将信息保存在文本文件中。`

示例

```x = optimvar('x',2); show(x)```
``` [ x(1) ] [ x(2) ] ```

```obj = log(1 + 100*(x(2) - x(1)^2)^2 + (1 - x(1))^2); show(obj)```
``` log(((1 + (100 .* (x(2) - x(1).^2).^2)) + (1 - x(1)).^2)) ```

```cons = x(1)^2 + x(2)^2 <= 1; show(cons)```
``` (x(1).^2 + x(2).^2) <= 1 ```

```prob = optimproblem("Objective",obj,"Constraints",cons); show(prob)```
``` OptimizationProblem : Solve for: x minimize : log(((1 + (100 .* (x(2) - x(1).^2).^2)) + (1 - x(1)).^2)) subject to : (x(1).^2 + x(2).^2) <= 1 ```

```x0.x = [0 0]; [sol,fval,exitflag] = solve(prob,x0)```
```Solving problem using fmincon. Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance. ```
```sol = struct with fields: x: [2x1 double] ```
```fval = 0.0447 ```
```exitflag = OptimalSolution ```

`sol.x`
```ans = 2×1 0.7864 0.6177 ```