For many applications, you can generate MEX functions to accelerate MATLAB® algorithms. If you have a Fixed-Point Designer™ license, you can generate MEX functions to accelerate fixed-point MATLAB algorithms. After generating a MEX function, test it in MATLAB to verify that its operation is functionally equivalent to the original MATLAB algorithm. Then compare the speed of execution of the MEX function with that of the MATLAB algorithm. If the MEX function speed is not sufficiently fast, you might improve it using one of the following methods:
Choosing a different C/C++ compiler.
It is important that you use a C/C++ compiler that is designed to generate high performance code.
The default MATLAB compiler for Windows® 64-bit platforms,
is designed to generate code quickly. It is not designed to generate
high performance code.