How to reduce decimal places displayed in symbolic matrix?
17 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Walter Roberson
2022-12-9
vpa(eta, DIGITS)
Note that exponents might not be affected in some cases
2 个评论
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
g(x) = vpa(f,3)
h = vpa(f,3)
digits(5)
h(x) = vpa(f,3)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!