Read the header data from a binary file using the readHeader function.
Write a header, followed by the data to a binary file named myfile.dat. The header is a 1-by-4 matrix of double precision values, followed by a 5-by-1 vector of single-precision values. The data is a sequence of 1000 double-precision values.
Read the header using a dsp.BinaryFileReader object. Specify the expected header structure. This structure specifies only the format of the expected binary file header and does not contain the exact values.
reader = dsp.BinaryFileReader("myfile.dat");
s = struct("A",zeros(1,4),"B",ones(5,1,"single"));
reader.HeaderStructure = s;
Header structure of the binary file, returned as a structure. Each field of the
structure is a real matrix of a built-in type. For example, if you specify the
HeaderStructure property of the
dsp.BinaryFileReader object to
struct('field1',1:10,'field2',single(1)), the object writes a
header formed by 10 double-precision values, (1:10), followed by one single precision
value, single(1). If you do not specify a header, the object returns an empty structure,
struct([]).
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: United States.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.