How to reduce decimal places displayed in symbolic matrix?
조회 수: 12 (최근 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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Numbers and Precision에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!