Search code examples
matlabprintingoctavesymbolic-math

How to print symfunc in Octave so it looks human-typed as opposed of human-written?


I'm trying to see a laplace transform applied to a symbolic function, but it doesn't look like I would want to.

; file.m
syms t

f(t) = (3*t - 2) * cos(t);

laplace(f)

outputs

ans = (sym)

     2       / 2    \
  3*s  - 2*s*\s  + 1/ - 3
  -----------------------
                 2
         / 2    \
         \s  + 1/

and I want

ans = (sym) (3*2^2 - 2*s*(s^2 + 1) - 3)/(s^2 + 1)^2

Solution

  • sympref display flat
    

    See here: https://octave.sourceforge.io/symbolic/function/sympref.html

    Also possibly useful: https://octave.sourceforge.io/symbolic/function/@sym/pretty.html