Using Build Scripts
If you use codegen to generate code from the command line, use build
scripts to call codegen to generate MEX functions from your MATLAB® function.
A build script automates a series of MATLAB commands that you want to perform repeatedly from the command line, saving you time and eliminating input errors. For instance, you can use a build script to clear your workspace before each build and to specify code generation options.
Here is an example of a build script to run codegen to process
lms_02.m:
close all;
clear all;
clc;
N = 73113;
codegen -report lms_02.m ...
-args { zeros(N,1) zeros(N,1) } close alldeletes figures whose handles are not hidden. Seeclosein the MATLAB Graphics function reference for more information.clear allremoves variables, functions, and MEX-files from memory, leaving the workspace empty. It also clears breakpoints.Note
Remove the
clear allcommand from the build scripts if you want to preserve breakpoints for debugging.clcclears all input and output from the Command Window display, giving you a “clean screen.”N = 73113sets the value of the variableN, which represents the number of samples in each of the two input parameters for the functionlms_02codegen -report lms_02.m -args { zeros(N,1) zeros(N,1) }callscodegento generate C code for filelms_02.musing the following options:-reportgenerates a code generation report-args { zeros(N,1) zeros(N,1) }specifies the properties of the function inputs as a cell array of example values. In this case, the input parameters are N-by-1 vectors of real doubles.