How to reduce decimal places displayed in symbolic matrix?

30 ビュー (過去 30 日間)
Ali
Ali 2022 年 12 月 9 日
コメント済み: Walter Roberson 2022 年 12 月 10 日
Hi, I have a matrix which contains symbolic elements. I'd like to decrease decimal count display to enhance readability.
Here is my matrix. I just copied the output of an attempt, please ignore the vpa.
syms t Omega
eta(Omega) = [(vpa("8000.0")*cos(Omega*t + vpa("0.78539816339744830961566084581988"))*(vpa("26838195793182970854745861920038.0")*Omega^2 - vpa("2.4154462400944206989319304935157e+34")))/(vpa("4.153837486827862102824397063376e+34")*Omega^4 - vpa("3.7425286527196553136998040116897e+37")*Omega^2 + vpa("3.6554306435273366948203088051441e+37")); -(vpa("0.0152587890625")*cos(Omega*t + vpa("0.78539816339744830961566084581988"))*(vpa("9.7133610940578263277504767935649e+35")*Omega^2 - vpa("9.4976141444561753442642817416859e+35")))/(vpa("4.153837486827862102824397063376e+34")*Omega^4 - vpa("3.7425286527196553136998040116897e+37")*Omega^2 + vpa("3.6554306435273366948203088051441e+37"))]
format short
does NOT help. I believe it's because the matrix has symbolic elements.

採用された回答

Walter Roberson
Walter Roberson 2022 年 12 月 9 日
vpa(eta, DIGITS)
Note that exponents might not be affected in some cases
  2 件のコメント
Ali
Ali 2022 年 12 月 10 日
Hi, thanks for your answer. Unfortunately, this doesn't work when assigning to a symbolic function.
>> q_hat(Omega) = vpa(q_hat(Omega),3)
q_hat(Omega) =
(27746.870093822479248046875 + 27746.870093822479248046875i)/(1000000.0*Omega^4 - 900981000.0*Omega^2 + 880012917.0)
-(0.0000000000000022737367544302526432562150870628*(Omega^2*(6219777023972212736.0 + 6219777023972212736.0i) - 5591697720268541657088.0 - 5591697720268541657088.0i))/(1000000.0*Omega^4 - 900981000.0*Omega^2 + 880012917.0)
>> q_hat = vpa(q_hat(Omega),3)
q_hat =
(2.77e+4 + 2.77e+4i)/(1.0e+6*Omega^4 - 9.01e+8*Omega^2 + 8.8e+8)
-(2.27e-15*(Omega^2*(6.22e+18 + 6.22e+18i) - 5.59e+21 - 5.59e+21i))/(1.0e+6*Omega^4 - 9.01e+8*Omega^2 + 8.8e+8)
>>
Walter Roberson
Walter Roberson 2022 年 12 月 10 日
It looks to me as if at the time you create a symbolic function using the notation of symbolic subscript on the left-hand side, it looks at the current digits setting and locks that in to the function.
However, if the right hand side of the expression is a symbolic function and you do not use the symbolic variable subscript on the left hand side, it does not do that.
syms x
f(x) = sym('0.0000000000000022737367544302526432562150870628')*x
f(x) = 
g(x) = vpa(f,3)
g(x) = 
h = vpa(f,3)
h(x) = 
digits(5)
h(x) = vpa(f,3)
h(x) = 

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumbers and Precision についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by