The recommended workflow for generating C code from a MATLAB function using the 'codegen' command. These are the steps: 1. Add the %#codegen directive to the MATLAB function to indicate that
Test the output of generated code by using MATLAB® unit tests with MATLAB® Coder™.
Test external C code by using MATLAB® unit tests with MATLAB® Coder™.
Register and use a Microsoft® Visual C/C++ (MSVC) toolchain running on a 64-bit Windows® platform to compile a 32-bit dynamic link library (DLL). This example uses a Microsoft® compiler.
Control whether structure arguments to generated entry-point functions are passed by reference or by value.
Generate a standalone C library from MATLAB code that implements a simple Sobel filter that performs edge detection on images. The example also shows how to generate and test a MEX function in
Generate C code for a MATLAB Kalman filter function,'kalmanfilter', which estimates the position of a moving object based on past noisy measurements. It also shows how to generate a MEX
Generate a standalone C library from MATLAB code that reads a file from disk using the standard C functions fopen/fread/fclose. To call these C functions, the MATLAB code uses the
Generate a MEX function and C source code from MATLAB code that performs portfolio optimization using the Black Litterman approach.
Use code replacement libraries to replace operators and functions in the generated code. The MATLAB code described illustrates the replacement capabilities. With each example MATLAB
Generate a standalone C library from MATLAB code that applies a simple histogram equalization function to images to improve image contrast. The example uses parfor to process each of the
Generate code for a MATLAB algorithm that runs a simulation of bouncing "atoms" and returns the result after a number of iterations. There are no upper bounds on the number of atoms that the
These examples are using Einstein's General Relativity to calculate geodesics in curved space-time.
Accelerate the execution of a MATLAB algorithm that uses MATLAB classes. The classes create a reverberation effect, that is, the "echo" you hear in a large empty room.
Write a MATLAB function that uses structure arrays so that it is suitable for code generation. For code generation, you must first create a scalar template version of the structure before
Generate a MEX function from a MATLAB function, 'compute_average', that uses persistent variables. It illustrates that you must clear the state of persistent variables before using the
Pack and unpack data using the provided packData and unpackData functions
This example shows how to generate code from packData and unpackData