필터 지우기
필터 지우기

How to reduce decimal places displayed in symbolic matrix?

조회 수: 12 (최근 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 CenterFile Exchange에서 Numbers and Precision에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by