From: Nick on
I'm struggling with putting my data into a cell array format that the uitable will accept.

I have data like this...
A=[73424 100 55.56 65;
73420 200 54.56 67;...]

I have no problem getting the numbers into the uitable as shown but I want to convert them and put it in. I'm having lots of problems understanding how to get this into a cell array so that the uitable will insert the data in various rows and 4 columns. It keeps putting all the data into one row or column.

Ideally I would do something like
B={datestr(A(:,1)) num2str(A(:,2)) num2str(A(:,3)) char(A(:,4))};
set(uitable,'Data',B)
and the first column would be dates, the second and third would be a string of numbers and the forth would be the ascii character converted from 65...67....

Thanks for any help you can give.
From: us on
"Nick " <notavail(a)gmail.com> wrote in message <hq2j8g$aee$1(a)fred.mathworks.com>...
> I'm struggling with putting my data into a cell array format that the uitable will accept.
>
> I have data like this...
> A=[73424 100 55.56 65;
> 73420 200 54.56 67;...]
>
> I have no problem getting the numbers into the uitable as shown but I want to convert them and put it in. I'm having lots of problems understanding how to get this into a cell array...

a hint:

help num2cell;

us
From: Nick on
>
> a hint:
>
> help num2cell;
>
> us

Thanks for the hint but I guess I'm still not seeing how you can now convert the cell of numbers to the 1x1 cell of strings I'm going to need for the uitable. Maybe there's someway to use cellfun on the new cell to convert it to dates and letters? I couldn't get it to work though.
From: us on
"Nick " <notavail(a)gmail.com> wrote in message <hq2nfi$8tc$1(a)fred.mathworks.com>...
> >
> > a hint:
> >
> > help num2cell;
> >
> > us
>
> Thanks for the hint but I guess I'm still not seeing how you can now convert the cell of numbers to the 1x1 cell of strings I'm going to need for the uitable. Maybe there's someway to use cellfun on the new cell to convert it to dates and letters? I couldn't get it to work though.

one of the many solutions

% the data
m=[
73424 1 2 65
74424 11 122 72
];
% the engine
% - a macro
fh=@(m,x) {datestr(m(x,1)),num2str(m(x,2)),num2str(m(x,3)),char(m(x,4))};
c=arrayfun(@(x) fh(m,x),1:size(m,1),'uni',false);
c=cat(1,c{:});
% the result
disp(c);
%{
'10-Jan-0201' '1' '2' 'A'
'07-Oct-0203' '11' '122' 'H'
%}
% now
set(uitable,'Data',c);

us
From: Nick on
Thank you. That works nicely.