Is there a way to force the format of symbolic equations to list the symbols in the order that they were entered?

2 visualizaciones (últimos 30 días)
I am trying to enter a symbolic equation to be displayed in a LiveScript but the output is always re-arranged from the order I entered the equation. Is there a way to force the output to display in the symbol order/format that it was entered? I realize the mathematically the formulas are equal but it can lead to confusion in many cases. For example, in the following screen shot, look at the order of x_L and x_E in the last equation. At first glance it looks as if the sign has changed on each squared term even though it is mathematically correct due to terms being squared:

Respuesta aceptada

Walter Roberson
Walter Roberson el 5 de Feb. de 2018
No, there is no way to do that in livescript. Doing this in the Symbolic Toolbox at all would require using feval(symengine) or evalin(symengine) to create a formula with a series of embedded hold() calls .
Even then, the symbolic _plus operation and _subtract operation and _multiply operation all know about commutivity, so you might have to create a new MuPAD DOM with appropriate slots for operations that somehow held the order until you asked it specifically to evaluate (at which point it would be re-order time.)
Livescript does not support formatting of internal hold() operations into nice display text.

Más respuestas (1)

Query generator
Query generator el 27 de Feb. de 2025
Editada: Walter Roberson el 27 de Feb. de 2025
I know this is a very old question but, in case anyone else was wondering, have a look at the following - this should display the equation as written:
clear;
u = symunit;
syms a b c d e f
equation_1_str = 'f == e*b*c + a + a^2/(d*c^2)';
displayFormula(equation_1_str)
equation_1_syms = str2sym(equation_1_str);
disp(equation_1_syms)
% Note, the symbolic conversion rearranges the equation.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by