User`s guide

Using xpctarget.fs Objects
in xPC Target format. The data must be a vecto r of bytes (uint8). To convert
the data to
uint8, use a command like the following:
data2 = uint8(data2');
This section assumes that you have a variable, data2,thatcontainsdatain
the xPC Target file format (see “Retrieving the Contents of a File from the
Target PC to the Host PC” on page 9-11):
1 In the MATLAB window, change folder to the folder that contains the xPC
Target format file.
2 Type
new_data2=readxpcfile(data2);
The readxp cfi le 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, o f w hich one of the elements is an array of doubles, data.
The
data member is also appended with a time stamp vector. A ll data is
returned as doubles, which represent the real-world values of the original
Simulink signals at the specified time s during targ et executio n.
You can view or examine the signal data. You can also plot the data with
plot(new_data2.data).
If you are using the xPC Target software in StandAlone mode, you can extract
the data from the data file if you know the number of signals in the scope
and file header size. If you know these numbers, you can extract the data.
Note the following:
Firstdeterminethefileheadersize. Toobtainthefileheadersize,ignore
the first eight bytes of the file. The next four bytes store the header size as
an unsigned integer.
After the header size number o f bytes, the file stores the signals
sequentially as doubles. For e xample, assume the scope has three signals,
x, y,andz. Assume tha t x[0] is the value of x at sample 0, x[1] is the
valueatsample1,andsoforth,and
t[0], t[1] are the simulation time
values at samples 0, 1, and so forth, respectively. The file saves the data
using the following pattern:
9-13