Sysquake Pro – Table of Contents
Sysquake for LaTeX – Table of Contents
MAT-file Input/Output
matfiledecode
Decode the contents of a MATLAB MAT-file.
Syntax
var = matfiledecode(fd) var = matfiledecode(data) var = matfiledecode(..., ignoreErr)
Description
matfiledecode(fd) reads data from file descriptor fd until the end of the file. The data must be the contents of a MATLAB-compatible MAT-file. They are made of 8-bit bytes; no text conversion must take place. The result is a structure whose fields have the name and the contents of the variables saved in the MAT-file.
Instead of a file descriptor, the data can be provided directly as the argument. In that case, the argument data must be an array, which can be read from the actual file with fread or obtained from a network connection.
Only arrays are supported (scalar, matrices, arrays of more than two dimensions, real or complex, numeric, logical or char). A second input argument can be used to specify how to handle data of unsupported types: with false (default value), unsupported types cause an error; with true, they are ignored.
Example
fd = fopen('data.mat'); s = matfiledecode(fd); fclose(fd); s s = x: real 1x1024 y: real 1x1024
See also
matfileencode
Encode the contents of a MATLAB MAT-file.
Syntax
matfileencode(fd, s) matfileencode(s)
Description
matfileencode(fd,s) writes the contents of structure s to file descriptor fd as a MATLAB-compatible MAT-file. Each field of s corresponds to a separate variable in the MAT-file. With one argument, matfileencode(s) writes to the standard output (which should be uncommon since MAT-files contain non-printable bytes).
Only arrays are supported (scalar, matrices, arrays of more than two dimensions, real or complex, numeric, logical or char).
Examples
s.a = 123; s.b = 'abc'; fd = fopen('data.mat', 'wb'); matfileencode(fd, s); fclose(fd);
Function variables can be used to save all variables:
v = variables; fd = fopen('var.mat', 'wb'); matfileencode(fd, v); fclose(fd);