From: Walter Roberson on
Tracy wrote:

> actually "data" is a 1xM array of char that i have read from a tcpip
> connection.
> but i am getting closer. I added this
> stripped_data=strrep(data, char(0), ' ');
> celldata = textscan(stripped_data, '%8c%8c%32c%32c%6c%256c');

Don't forget to make allowance for the blanks that are now there between fields.

Instead of using strrep, you could more efficiently,

data(data == char(0)) = ' ';

> and then celldata (is a 1x6 cell) looks like this
>
> celldata =
> [56x8 char] [56x8 char] [56x32 char] [56x32 char] [56x6
> char] [56x256 char]
>
> which is very close! But what i need is a matrix of cells (so i can
> give it to my table object using
> set(handles.log_table, 'Data', celldata);
>
> in this case i would want celldata to be a 6 column, 56 row matrix. Can
> you help me with this conversion?

T = cellfun(@cellstr, celldata);
horzcat(T{:})

I think.
From: Tracy on
Walter Roberson <roberson(a)hushmail.com> wrote in message <hup0u0$li8$1(a)canopus.cc.umanitoba.ca>...
> Tracy wrote:
>
> > actually "data" is a 1xM array of char that i have read from a tcpip
> > connection.
> > but i am getting closer. I added this
> > stripped_data=strrep(data, char(0), ' ');
> > celldata = textscan(stripped_data, '%8c%8c%32c%32c%6c%256c');
>
> Don't forget to make allowance for the blanks that are now there between fields.
>
> Instead of using strrep, you could more efficiently,
>
> data(data == char(0)) = ' ';
>
> > and then celldata (is a 1x6 cell) looks like this
> >
> > celldata =
> > [56x8 char] [56x8 char] [56x32 char] [56x32 char] [56x6
> > char] [56x256 char]
> >
> > which is very close! But what i need is a matrix of cells (so i can
> > give it to my table object using
> > set(handles.log_table, 'Data', celldata);
> >
> > in this case i would want celldata to be a 6 column, 56 row matrix. Can
> > you help me with this conversion?
>
> T = cellfun(@cellstr, celldata);
> horzcat(T{:})
>
> I think.

thanks for your help. I tweaked it a bit and this was what worked.


cc= cellfun(@cellstr, celldata, 'UniformOutput', 0);
[source{1:6}] = deal(t.Addr);
# re-ordered the columns
set(handles.log_table, 'Data', [cc{3} cc{2} cc{1} cc{4} source' cc{5}]);
First  |  Prev  | 
Pages: 1 2 3
Prev: PI
Next: Carriage return in mex files