フィルターのクリア

Symbols to numeric values

1 回表示 (過去 30 日間)
jack london
jack london 2022 年 1 月 18 日
コメント済み: jack london 2022 年 1 月 18 日
Hi everyone,
I have two question about my codes:
I have code below When it is running on R2021a the output is:
How I convert to numeric values I try to see results as a :
X: -1
Y: -2
Z: 0
Note: R2021b gives numeric result but I use R2021a matlab software.
2. The second question is my codes ends with numeric values of X,Y and Z . I want to see final results as a equation below, How I code this result? Thank you.
syms A B C
syms X Y Z integer
eqn = (B*C^-1)^X * (B)^Y * (A*B^-3)^Z * (B^3*C^-1) == A^0*B^0*C^0
seqn = simplify(lhs(eqn)) == simplify(rhs(eqn))
collect(lhs(seqn),C)
powers = findSymType(ans, 'power')
need_to_solve = arrayfun(@(expression) children(expression,2), powers)
syms X Y Z %remove assumptions
sol = solve(need_to_solve)

採用された回答

Walter Roberson
Walter Roberson 2022 年 1 月 18 日
I already showed you
X = double(sol.X)
Y = double(sol.Y)
Z = double(sol.Z)
... about 11 hours ago.
To get that format of display, you can either text() everything into place, or you can use displayFormula https://www.mathworks.com/help/symbolic/displayformula.html -- though that might only work if you are using LiveScript, perhaps.
  2 件のコメント
jack london
jack london 2022 年 1 月 18 日
Thank you! I didn't see your answer before.
jack london
jack london 2022 年 1 月 18 日
Actually I search the link you given, but still I can't find suitable codes
I use displayFormula and rewrite function but it gives error, which function should I use for this representation?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by