Convert maple expression into MATLAB

Alec Jacobson

December 01, 2019

weblog/

This will convert a maple expression into a string as a matlab expression

with(StringTools):
MATLAB := (s) -> SubstituteAll(SubstituteAll(SubstituteAll(SubstituteAll(convert(simplify(s,size),string),"*",".*"),"^",".^"),"/","./"),"Pi","pi"):

As in

MATLAB(x*y^z/w);

will output:

"x.*y.^z./w"

It'd be cool to get rid of the " at the beginning and end, too.