Load compile-time constants from MAT-file or ASCII file into caller workspace
loads
compile-time constants from S
= coder.load(filename
)filename
.
If filename
is a MAT-file, then
coder.load
loads variables from the MAT-file into
a structure array.
If filename
is an ASCII file, then
coder.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.
Arguments to coder.load
must be
compile-time constants.
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 the save
function.
Furthermore, you cannot use coder.extrinsic
with save
.
Prior to generating code, you can use save
to save
workspace data to a file.
coder.load
loads data at compile
time, not at run time. If you are generating MEX code or code for Simulink® simulation,
you can use the MATLAB function load
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 by coder.load
changes,
the software rebuilds the code.