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:
Aarjav Khara
Aarjav Khara 2020 年 12 月 3 日
Thank you!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFunctions についてさらに検索

製品

リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by