Live script output shortened by 'where'

3 views (last 30 days)
Hendrik Lorenz
Hendrik Lorenz on 12 Jun 2019
Commented: Ralf Hillebrand on 9 Mar 2020
When I run a live script with symbolic expressions that have long terms the output is shortened by the introduction of new variables. How can I avoid this behaviour?
An example given here
syms theta_1 theta_2 theta_3 theta_4 theta_5
syms g
syms u_1 u_2 u_3
% define symbols
for i = 1:1:6
eval(strcat("syms x_", num2str(i)))
end
dx_1dt = theta_1*x_4 - theta_3*x_6*sign(x_1 - x_2)*sqrt(2*g*abs(x_1 - x_2));
dx_2dt = theta_3*x_6*sign(x_1 - x_2)*sqrt(2*g*abs(x_1-x_2))-theta_4*sign(x_2-x_3)*sqrt(2*g*abs(x_2-x_3));
dx_3dt = theta_4*sign(x_2-x_3)*sqrt(2*g*abs(x_2-x_3))+theta_2*x_5*sqrt(2*g*x_3);
dx_4dt = u_1;
dx_5dt = u_2;
dx_6dt = u_3;
f_dyn = [dx_1dt; dx_2dt; dx_3dt; dx_4dt; dx_5dt; dx_6dt]
See also the attached screenshot
Capture.PNG
Plenty of space to print the formula fully
  1 Comment
Ralf Hillebrand
Ralf Hillebrand on 9 Mar 2020
By default, symbolic outputs are abbreviated to make the output as compact as possible. You can change the default behavior so that all symbolic outputs are expanded. To change the default, use this command:
sympref('AbbreviateOutput',false);
Please note that this preference is persistent over MATLAB sessions. To revert back to the original default, set the value to true.

Sign in to comment.

Answers (0)

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!