I work both with MATLAB (the $$$$ version of Octave) and with Mathematica quite regularly, and I'm pretty sure that it is not possible to implement a parser / porter that automatically converts from Mathematica to another. First, MATLAB / Octave does not support pattern matching or rewriting of terms or functional programming, all of which are the most common and optimal coding styles in Mathematica.
For example, consider a pure function (Mathematica)
f =
There really is no equivalent in MATLAB / Octave. Anonymous functions are pretty close, and you can write them as (MATLAB / Octave)
g=@(x)x.^2;
, Mathematica , , MATLAB //. , , , , .
, MATLAB/Octave, - / SetDelayed := . ,
f := a
f a f. , :
g = @(x)a*x.^2;
a , . .
, Mathematica, . Mathematica, . , , .
, Mathematica MATLAB/Octave, ToMatlab. , Mathematica MATLAB. :
expr = Sin[x + x^3] + ArcSin[y];
ToMatlab[expr]
Out[1]= sin(x + x.^3) + asin(y)