File Exchange

image thumbnail

Using Legacy Code with MATLAB Coder

version (7.87 KB) by

Some examples on building MATLAB code with existing C code

1 Download


View License

This file exchange submission contains some examples on how to include
custom C code when using MATLAB Coder, and how to support an implementation
for standard MATLAB functions not supported by MATLAB Coder. It also shows
how the build process can be more streamlined.
More information may be added here later, but for the moment, the examples must be understood by reading them.
The code in this example is described in more detail in this article:

Comments and Ratings (3)


Thanks for the share!

For one reason the MEX-ed my_alg-routine is slower then the original one.

tic; my_alg(1e3); toc;
Elapsed time is 0.069168 seconds.
tic; my_alg_mex(1e3); toc;
Elapsed time is 1.410066 seconds.

Is that reasonable or I'm doing something wrong?

Stefano Gianoli

Excellent work! May I suggest to change the last line in the script kvs_script.m to:

>codegen('-config:mex', '-I', fullfile('.', '+mlcutils'), '-o', fullfile('.', '+mlcutils', 'kvs_mex'), 'kvs', '-args', 'ARGS')

so the script will run platform independent.


Good submission. All three examples worked.


Updated license


Added link to article.


Added some code anylsis relevant comments in some files.

MATLAB Release
MATLAB 8.5 (R2015a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today