How to reduce decimal places displayed in symbolic matrix?

6 views (last 30 days)
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.

Accepted Answer

Walter Roberson
Walter Roberson on 9 Dec 2022
vpa(eta, DIGITS)
Note that exponents might not be affected in some cases
  2 Comments
Walter Roberson
Walter Roberson on 10 Dec 2022
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) = 

Sign in to comment.

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!