readmat - Matrix of data from RTDX™ channel

Syntax

data = readmat(rx,channelname,'datatype',siz,timeout)
data = readmat(rx,channelname,'datatype',siz)

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 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.

MATLAB® software supports reading five data types with readmat:

datatype StringData Format

double

Double-precision floating point values. 64 bits.

int16

16-bit signed integers

int32

32-bit signed integers

single

Single-precision floating point values. 32 bits.

uint8

Unsigned 8-bit integers

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 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.

MATLAB software supports reading five data types with readmat:

datatype StringData Format

double

Double-precision floating point values, 64 bits.

int16

16-bit signed integers.

int32

32-bit signed integers.

single

Single-precision floating point values. 32 bits.

uint8

Unsigned 8-bit integers.

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, replace the listed channels with your current ones.

cc = ticcs;
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,'double',25,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.

out_array = readmat('ochannel','double',[5 5])

See Also

readmsg, writemsg

  


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