Products & Services Solutions Academia Support User Community Company

Learn more about xPC Target   

fread - Read open target PC file

Syntax

MATLAB command line

A = fread(file_obj,file_ID)
A = file_obj.fread(file_ID)
A = fread(file_obj, file_ID, offset, numbytes)
A = file_obj.fread(file_ID, offset, numbytes)

Arguments

file_obj

Name of the xpctarget.fs object.

file_ID

File identifier of the file to read.

offset

Position from the beginning of the file from which fread can start to read.

numbytes

Maximum number of bytes fread can read.

Description

Method of xpctarget.fs objects. From the host PC, A = fread(file_obj,file_ID) or A = file_obj.fread(file_ID) reads all the binary data from the file on the target PC and writes it into matrix A. The file_ID argument is the file identifier associated with an open file (see fopen).

From the host PC, A = fread(file_obj, file_ID, offset, numbytes) or A = file_obj.fread(file_ID, offset, numbytes) reads a block of bytes from file_ID and writes the block into matrix A. The offset argument specifies the position from the beginning of the file from which this function can start to read. numbytes specifies the maximum number of bytes to read. To get a count of the total number of bytes read into A, use the following:

 count = length(A);

length(A) might be less than the number of bytes requested if that number of bytes are not currently available. It is zero if the operation reaches the end of the file.

Examples

Open the file data.dat in the target PC file system object fsys. Assign the resulting file handle to a variable for reading.

h = fopen(fsys,'data.dat') or fsys.fopen('data.dat')
ans =
     2883584
d = fread(h);

This reads the file data.dat and stores all of the contents of the file to d. This content is in the xPC Target file format.

See Also

xPC Target file object methods fclose, fopen, and fwrite.

MATLAB fread function.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS