coder.read
Syntax
Description
reads from the dataFromFile
= coder.read(fileName
)fileName.coderdata
storage file and returns the data
stored within the file. This syntax works for a constant fileName
input
only. Use this function in your MATLAB® code for which you want to generate C/C++ code. The generated code performs
the data read at run time.
To store your workspace variables in a .coderdata
file, use the
coder.write
function in MATLAB.
uses the information contained in dataFromFile
= coder.read(fileName
,TypeHeaderFrom=typeHeaderFilename
)typeHeaderFilename
to determine the
type and size of the data to be read from fileName
. Both
fileName
and typeHeaderFilename
must be
.coderdata
files. The typeHeaderFilename
argument
must be a compile-time constant and the file that this name represents must exist in your
current directory during code generation.
Each .coderdata
file contains a type header
that specifies the type and size of the data stored in the file. The code generated for the
coder.read
function can read any .coderdata
file at
run-time, while the file type and size is consistent with the type and size information that
you supply using the typeHeaderFilename
file during code generation.
To create a .coderdata
file to use with the
TypeHeaderFrom
argument, use the coder.write
function in MATLAB.
[
suppresses run-time errors during a read operation. dataFromFile
,errID
] = coder.read(___)errID
is a
coder.ReadStatus
enumeration object. If any errors occur,
coder.read
returns the first error through errID
and
dataFromFile
returns unusable content. Use this option to test the
generated code for targets for which run-time errors are disabled.
Examples
Input Arguments
Output Arguments
Extended Capabilities
Version History
Introduced in R2023a
See Also
coder.write
| coder.load
| fread
| fwrite
| fscanf
| fprintf