美化Matlab的输出又名人类可读形式的输出? [英] Beautifying the output of Matlab aka human-readable form for output?
问题描述
syms x y z;
solve(x==y+1, y^2==z,z==9)
ans =
x: [2x1 sym]
y: [2x1 sym]
z: [2x1 sym]
,现在我想看到类似Mathematica为Solve[{x == y + 1, y^2 == z, z == 9}, {x, y, z}]
输出{{x->-2,y->-3,z->9},{x->4,y->3,z->9}}
的结果.工作区窗口,然后是变量编辑器,向我显示了此,但我仍然看不到存储的实际值在那里.
and now I want to see the results like Mathematica outputting {{x->-2,y->-3,z->9},{x->4,y->3,z->9}}
for Solve[{x == y + 1, y^2 == z, z == 9}, {x, y, z}]
. The workspace window and then variable editor shows me this but I still cannot see the real values stored there.
如何以易于理解的形式(又称为美化形式)查看Matlab的输出?
推荐答案
solve
状态:
求解方程组时,使用一个输出参数以结构数组的形式返回解决方案
When solving a system of equations, use one output argument to return the solutions in the form of a structure array
结果作为结构返回,因此您可以访问每个字段以查看其值.该文档提供了如何执行此操作的示例:
The result is returned as a struct, so you can access each field to see its value. The documentation brings an example of how to do it:
S = solve(x==y+1, y^2==z, z==9);
[S.x, S.y, S.z]
这应该导致:
ans =
4 3 9
-2 -3 9
或者,您可以通过指定多个输出参数以单独的变量返回解决方案:
Alternatively, you can return the solutions in separate variables by specifying multiple output arguments:
[solx, soly, solz] = solve(x==y+1, y^2==z, z==9)
这将导致:
solx =
4
-2
soly =
3
-3
solz =
9
-9
这篇关于美化Matlab的输出又名人类可读形式的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!