Home > other >  Matlab Livescript Problem: Cannot control display of subscripted symbols in exponents?
Matlab Livescript Problem: Cannot control display of subscripted symbols in exponents?

Time:01-06

The following code produces an unexpected output (R2022b MacOS Monterey 1.26, Symbolic Math toolbox installed). The output is unexpected because the output display equation seem to insist upon writing theta2 before theta1, which can really impair the usefulness of the displayed livescript output equation:

syms e theta_1 theta_2
disp(e^(theta_1   theta_2))
disp(e^(theta_1 - theta_2))

the livescript displayed output is:

enter image description here

The first displayed equation is an unexpected nuisance. The second displayed equation is a real pain in the neck.

Is there any solution to this? I guess I could use LATEX but not really what I want to do. I could really use a good reference on the nuances of the many Matlab equation display commands.

Here is a screenshot of my display:

enter image description here

CodePudding user response:

Type sympref('PolynomialDisplayStyle','descend'); before the disp commands. This will change the order with which the theta variables are displayed and will therefore affect the final output:

clc; clear all;
sympref('PolynomialDisplayStyle','descend');

syms e theta_1 theta_2;
disp(e^(theta_1   theta_2));
disp(e^(theta_1 - theta_2));

which yields

enter image description here

On the other hand, using sympref('PolynomialDisplayStyle','ascend'); produces the weird output you showed in your post.

More info about sympref here.

  • Related