Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

fread (MathScript RT Module Function)

LabVIEW 2011 MathScript RT Module Help

Edition Date: June 2011

Part Number: 373123B-01

»View Product Info

Owning Class: support

Requires: MathScript RT Module

Syntax

a = fread(fid)

a = fread(fid, n)

a = fread(fid, n, type)

a = fread(fid, n, type, s)

a = fread(fid, n, type, s, byte)

[a, b] = fread(fid)

[a, b] = fread(fid, n)

[a, b] = fread(fid, n, type)

[a, b] = fread(fid, n, type, s)

[a, b] = fread(fid, n, type, s, byte)

Description

Reads binary data from a file.

Examples

Inputs

Name Description
fid Specifies the identifier for the file you want to read. Use the fopen function to open a file and assign it an identifier. fid is an integer.
n Specifies the amount of data to read from the file specified by fid. LabVIEW discards all but the first two elements of n. If n is inf, LabVIEW reads the file until it reads all the data or an error occurs. n is a 32-bit signed integer or a 1D matrix of those values.
type Specifies the data type to read from the file specified by fid. If you specify s, you can add a positive integer of the form 'm*' before type. LabVIEW then skips s bytes after each m bytes it reads successfully. You also can add '=>' and a data type after type to specify the data type that LabVIEW returns. type is a string that accepts the following values.

'double' Reads 64-bit, double-precision, floating-point numbers.
'float32' Reads 32-bit, single-precision, floating-point numbers.
'float64' Reads 64-bit, double-precision, floating-point numbers.
'int16' Reads 16-bit signed integers.
'int32' Reads 32-bit signed integers.
'int64' Reads 64-bit signed integers.
'int8' Reads 8-bit signed integers.
'schar' Reads signed characters.
'single' Reads 32-bit, single-precision, floating-point numbers.
'uchar' (default) Reads unsigned characters.
'uint16' Reads 16-bit unsigned integers.
'uint32' Reads 32-bit unsigned integers.
'uint64' Reads 64-bit unsigned integers.
'uint8' Reads 8-bit unsigned integers.
s Specifies the number of bytes to skip after each m bytes as you specify in type. s is a positive integer.
byte Specifies the byte order, or endian form, to use when reading data. byte is a string that accepts the following values.

'b' Reads data in big-endian form.
'l' Reads data in little-endian form.
'n' (default) Reads data in the byte-ordering format of the host computer.

Outputs

Name Description
a Returns the data that LabVIEW read from the file specified by fid. a is a vector or matrix of 64-bit, double-precision, floating-point numbers.
b Returns the amount of data that LabVIEW read successfully from the file specified by fid. b is a positive integer.

Details

The following table lists the support characteristics of this function.

Supported in the LabVIEW Run-Time Engine Yes
Supported on RT targets Yes
Suitable for bounded execution times on RT Not characterized

Examples

fid = fopen('test.dat', 'r');
[a, b] = fread(fid, [10, Inf], '10*int8=>int32', 5);
fclose(fid);

Related Topics

fclose
fopen
fseek
fwrite


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit