Converting a symbolic matrix to a normal matrix

13 ビュー (過去 30 日間)
JR
JR 2017 年 7 月 12 日
回答済み: Matt J 2017 年 7 月 12 日
Say I have this from this link.
syms x y z
jacobian([x*y*z, y^2, x + z], [x, y, z])
It gives an output of
ans =
[ y*z, x*z, x*y]
[ 0, 2*y, 0]
[ 1, 0, 1]
What I want to do is to convert the above symbolic matrix to a normal where x=y=z=1 to have a final output of:
Final=
[ 1 1 1]
[ 0 2 0]
[ 1 0 1]

採用された回答

Star Strider
Star Strider 2017 年 7 月 12 日
Try this:
syms x y z
M = jacobian([x*y*z, y^2, x + z], [x, y, z]);
M = subs(M, {x,y,z},{1,1,1});
dM = double(M);
You can also create ‘M’ as a symbolic function:
syms x y z
M(x,y,z) = jacobian([x*y*z, y^2, x + z], [x, y, z]);
nM = M(1,1,1);
dM = double(nM);
The result is the same.

その他の回答 (1 件)

Matt J
Matt J 2017 年 7 月 12 日
J=jacobian([x*y*z, y^2, x + z], [x, y, z]);
Jnumeric = double(subs(J,[x,y,z],[1,1,1]))

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by