"Ricardo " <email@example.com> wrote in message news:firstname.lastname@example.org... > Hello everybody > > Is there any way to compile a function (.m) in order to optimize its > performance?
That's a difficult question.
> I don't know if you understand what I mean, but most of the functions of > Matlab are compiled and others not (for example, I think "rand" is a > compiled function but "randint" not). What I was wondering is if you can > build new (.m) functions to make them efficient, such the example of > "rand" function?
The only way you can create new built-in functions in the style of RAND is to get a job at MathWorks.
Depending on what exactly you're trying to do, creating a C++ MEX-file manually, preparsing the function using PCODE, or generating C/C++ code using MATLAB Coder and using that as the core of a MEX-file may be options. Alternately, identifying bottlenecks in the code using MATLAB Profiler and places where you may be able to implement your algorithm more efficiently with Code Analyzer may be sufficient to improve performance until it meets your needs.