The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Compile (.m) files to a build-in function
Replies: 3   Last Post: Dec 13, 2012 11:59 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 18,038
Registered: 12/7/04
Re: Compile (.m) files to a build-in function
Posted: Dec 13, 2012 9:47 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Ricardo " <> wrote in message
> 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.

Steve Lord
To contact Technical Support use the Contact Us link on

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.