coder.load
Load constants from MAT file or ASCII file at code generation time
Syntax
Description
loads
constant values from S = coder.load(filename)filename.
If
filenameis a MAT file, thencoder.loadloads variables from the MAT file into a structure array.If
filenameis an ASCII file, thencoder.loadloads data into a double-precision array.
coder.load loads data at code generation time,
also referred to as compile time. If you change the content of
filename after you generate code, the change is not
reflected in the behavior of the generated code.
loads only the specified variables from the MAT file
S = coder.load(filename,var1,...,varN)filename.
loads
only the variables that match the specified regular expressions.S = coder.load(filename,'-regexp',expr1,...,exprN)
treats S = coder.load(filename,'-mat',var1,...,varN)filename as a MAT file and loads only the specified
variables from the file.
treats S = coder.load(filename,'-mat','-regexp', expr1,...,exprN)filename as a MAT file and loads only the variables that
match the specified regular expressions.
Examples
Input Arguments
Output Arguments
Limitations
Arguments to
coder.loadmust be constants at code generation time.The output
Smust be the name of a structure or array without any subscripting. For example,S(i) = coder.load('myFile.mat')is not allowed.You cannot use
saveto save workspace data to a file inside a function intended for code generation. The code generator does not support thesavefunction. Furthermore, you cannot usecoder.extrinsicwithsave. Prior to generating code, you can usesaveto save workspace data to a file.
Tips
coder.load(filename)loads data at code generation time, not at run time. If you change the content offilenameafter you generate code, the change is not reflected in the behavior of the generated code. If you are generating MEX code or code for Simulink® simulation, you can use the MATLAB functionloadto load run-time values.If the MAT file contains unsupported constructs, use
coder.load(filename,var1,...,varN)to load only the supported constructs.If you generate code in a MATLAB Coder™ project, the code generator practices incremental code generation for the
coder.loadfunction. When the MAT file or ASCII file used bycoder.loadchanges, the software rebuilds the code.
Extended Capabilities
Version History
Introduced in R2013a
See Also
matfile | regexp | save | coder.write | coder.read (MATLAB Coder) | fread | fwrite | fscanf | fprintf