MATLAB: Matlab: Symbolic Toolbox deactivate automatic simplification

formulasMATLABsymbolicSymbolic Math Toolbox

I have a question concerning the symbolic toolbox. When I give matlab a symbolic formula it does automatic simplification in live script, but I want it to write the formula exactly as I gave it to matlab. Does anybody know how to do that or where I can look it up? I haven't been lucky with my search so far

Best Answer

That is not possible, and it is unlikely to ever be an option. Symbolic engines often have internal rewriting rules to put things into "canonical form" to make it easier to determine whether expressions are equal, which can be very important for reducing memory use and for performance reasons.
The internal symbolic engine (MuPAD) mechanism for postponing evaluation is to use hold() . Each evaluation strips off one layer of hold() . For example if you open a MuPad notebook and command
hold(hold(3))*hold(hold(5))
then because one layer of hold is stripped off at execution time, the result would be
hold(3)*hold(5)
If you had tried hold(3)*hold(5) directly then because one hold would be stripped off, you would get 15 directly .
There is no MATLAB interface provided for hold. You can try things like,
Hold = @(V) feval(symengine, 'hold', V)
Hold(3)*Hold(5)
but the result you will get will be
Warning: Unable to display symbolic object because 'symengine' was reset. Repeat commands to regenerate result.
> In sym/disp (line 44)
In sym/display>displayVariable (line 85)
In sym/display (line 47)