MATLAB Link for Code Composer Studio Development Tools | ![]() ![]() |
Read a matrix of values from an RTDX channel
Syntax
Description
data = readmat(rx,channelname,datatype,siz,timeout)
reads a matrix of data from an RTDX channel configured for read access. datatype
defines the type of data to read, and channelname
specifies the queue to read. readmat
reads the desired data from the RTDX link specified by rx
. Before you try to read from a channel, open and enable the channel for read access. Replace channelname
with the string you specified when you opened the desired channel. channelname
must identify a channel that you defined in the program loaded on the target processor. You cannot read data from a channel you have not opened and configured for read access. If necessary, use the RTDX tools provided in CCS IDE to determine which channels exist for the loaded program.
data
contains a matrix whose dimensions are given by the input argument vector siz
, where siz
can be a vector of two or more elements. To operate properly, the number of elements in the output matrix data
must be an integral number of channel messages.
When you omit the timeout
input argument, readmat
reads messages from the specified channel until the output matrix is full or the global timeout
period specified in rx
elapses.
Caution If the timeout period expires before the output data matrix is fully populated, you lose all the messages read from the channel to that point. |
MATLAB supports reading five data types with readmat
:
data = readmat(rx,channelname,datatype,siz)
reads a matrix of data from an RTDX channel configured for read access. datatype
defines the type of data to read, and channelname
specifies the queue to read. readmat
reads the desired data from the RTDX link specified by rx
. Before you try to read from a channel, open and enable the channel for read access. Replace channelname
with the string you specified to open and enable the desired channel. You cannot read data from a channel you have not opened and configured for read access. data
contains a matrix whose dimensions are given by the input argument vector siz
, where siz
can be a vector of two or more elements. To operate properly, the number of elements in the output matrix data
must be an integral number of channel messages.
When you include the timeout
input argument, readmat
reads messages from the specified channel until the output matrix is full or the timeout
period elapses.
Caution If the timeout period expires before the output data matrix is fully populated, you lose all the messages read from the channel to that point. |
MATLAB supports reading five data types with readmat
:
Examples
In this data read and write example, you write data to the target through the CCS IDE. You can then read the data back in two ways--either through read
or through readmsg
. To duplicate this example you need to have a program loaded on the target. The channels listed in this example, ichannel
and ochannel
, must be defined in the loaded program. If the current program on the target defines different channels, you can replace the listed channels with your current ones.
cc = ccsdsp; rx = cc.rtdx; open(rx,'ichannel','w'); enable(rx,'ichannel'); open(rx,'ochannel','r'); enable(rx,'ochannel'); indata = 1:25; % Set up some data. write(cc,0,indata,30); outdata=read(cc,0,25,'double',10) outdata = Columns 1 through 13 1 2 3 4 5 6 7 8 9 10 11 12 13 Columns 14 through 25 14 15 16 17 18 19 20 21 22 23 24 25
Now use RTDX to read the data into a 5-by-5 array called out_array
.
![]() | read | readmsg | ![]() |