4

Most of my Matlab functions can be converted with the mfile2sci function to Scilab functions except some functions that contain anonymous functions (for example f=@(x,y)sin(x)+log(y)). Is there a way to convert the anonymous functions to Scilab inline functions (for example, for the previous example deff('[z]=f(x,y)','z=sin(x)+log(y)')) so that I don't have to change my Matlab functions?

Dante
  • 611
  • 1
  • 7
  • 21
  • Scilab now has a `regexp` function. I am wondering if it is possible to extract that pattern out. Something like validMatlabFunctionNanme\s?=\s?@\(someText\) MathematicalExpression... – Foad S. Farimani Mar 21 '19 at 08:30

1 Answers1

1

Yes, in its current state the Matlab to Scilab translator mfile2sci fails to translate anonymous functions, but this behavior can be improved by the following patch:

https://codereview.scilab.org/#/c/20916/

However, be warned that anonymous function occur most of the time when using "solvers" like fsolve, optim, ode solvers (e.g. ode45, ode15s,...), and that statements using these are never translated to working Scilab statements (a warning is given).

Stéphane Mottelet
  • 2,853
  • 1
  • 9
  • 26