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?

 采纳的回答

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)

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Functions 的更多信息

产品

版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by