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?
Asked
Active
Viewed 1,306 times
4

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 Answers
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
-
thanks a lot. would you be kind to share the regular expression you have used here? – Foad S. Farimani Apr 02 '19 at 19:11
-
1Yes, you can find in the code of patched file at https://codereview.scilab.org/#/c/20916/2/scilab/modules/m2sci/macros/kernel/m2sci_syntax.sci – Stéphane Mottelet Apr 02 '19 at 19:23