Formatting Matlab's output to Command Window

I am trying to check a few symbolic equations by printing them to the Command Window. My Command Window prefrences are already defaulted to "short" output format for numeric values and doesn't give any issue when printing numeric values to the command window. However, when trying to display a symbolic equation, for example:
equation = (-66*cos( th1 + pi/2 ) - 0.99*x*cos( th1 + pi/2 ) + 0.99*y*sin( th1 + pi/2 )) / (cos( th1 + pi/2 )^2 + sin( th1 + pi/2 )^2 )
By simply using the disp(simplify(equation)) command, the following is printed to the Command Window:
-(222143115238362815690920839645245649785771639010720389686529839575*cos(th11 + pi/2) + 3291009114642412084309938365114701009965471731267159726697218048*x0*cos(th11 + pi/2) - 3291009114642412084309938365114750367196616874232894662022664290*y0*sin(th11 + pi/2))/(3291009114642412084309938365114750367196616874232894662022664290*(cos(th11 + pi/2)^2 + sin(th11 + pi/2)^2))
So, I tried using vpa(equation,2) to display the numerical values to 2 significant digits, the output is:
-(3.0e-64*(2.2e+65*cos(th11 + 1.6) + 3.3e+63*x0*cos(th11 + 1.6) - 3.3e+63*y0*sin(th11 + 1.6)))/(cos(th11 + 1.6)^2 + sin(th11 + 1.6)^2)
Is there a way to change the output format of the Command Window so that it shows the equation so that it is human reader friendly?

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 12월 3일
편집: Ameer Hamza 2020년 12월 3일

1 개 추천

The format short only applies to native numeric datatypes, e.g., double. Generally, it is preferable to display symbolic calculation in full precision. However, you can change the default display of symbolic numbers using sympref()
sympref('FloatingPointOutput', 1)
It will change the preference of symbolic toolbox to display values as floating point numbers. To revert back, run
sympref('FloatingPointOutput', 0)

댓글 수: 2

Deepak Gupta
Deepak Gupta 2020년 12월 3일
편집: Walter Roberson 2020년 12월 3일
Adding to Ameer's answer.
For more info on this you can follow the documentation:
Thank you!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Functions에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

2020년 12월 3일

편집:

2020년 12월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by