User`s guide

7 Working with Target PC Files and File Systems
7-12
data2=fread(fsys,h);
This reads the file data.dat and stores the contents of the file to data2. This
content is in the xPC Target file format.
4 Type
fsys.fclose(h);
This closes the file data.dat.
Before you can view or plot the contents of this file, you must convert the
contents. See “Converting xPC Target File Format Content to Bytes” on
page 7-12.
Converting xPC Target File Format Content to Bytes
If you have xPC Target file format content that you want to view or plot, you
need to convert that content to bytes. xPC Target provides the script
readxpcfile.m to convert xPC Target format content.
This section assumes that you have a variable,
data2, that contains data in the
xPC Target file format (see “Retrieving the Contents of a File from the Target
PC to the Host PC” on page 7-11):
1 In the MATLAB window, change directory to the directory that contains the
xPC Target format file.
2 Type
new_data2=readxpcfile(data2);
The readxpcfile script converts the format of data2 from the xPC Target
file format to an array of bytes. It also creates a structure for that file in
new_data2, of which one of the elements is an array of doubles, data. The
data member is also appended with a time stamp vector. All data is returned
as doubles, which represent the real-world values of the original Simulink
signals at the specified times during target execution.
You can view or examine the signal data. You can also plot the data with
plot(new_data2.data).