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
filename
is a MAT file, thencoder.load
loads variables from the MAT file into a structure array.If
filename
is an ASCII file, thencoder.load
loads 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.load
must be constants at code generation time.The output
S
must 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
save
to save workspace data to a file inside a function intended for code generation. The code generator does not support thesave
function. Furthermore, you cannot usecoder.extrinsic
withsave
. Prior to generating code, you can usesave
to 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 offilename
after 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 functionload
to 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.load
function. When the MAT file or ASCII file used bycoder.load
changes, 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