File Exchange

image thumbnail

Using Legacy Code with MATLAB Coder

version 1.1.0.1 (7.87 KB) by Anders Sollander
Some examples on building MATLAB code with existing C code

1 Download

Updated 01 Sep 2016

View Version History

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: http://www.mathworks.com/company/newsletters/articles/using-legacy-code-with-matlab-coder.html?refresh=true

Cite As

Anders Sollander (2021). Using Legacy Code with MATLAB Coder (https://www.mathworks.com/matlabcentral/fileexchange/51553-using-legacy-code-with-matlab-coder), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (3)

Michael

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.

Matthew

Good submission. All three examples worked.

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!