datestring in uitable problem with cells array
1 次查看(过去 30 天)
显示 更早的评论
I want to display a cell array in uitable, if I define, for example
c={'01-Feb-2008' 458;'08-Jun-2009' 5}
then
uitable('Data',c) it works correctly
while if I have something like this
c={cellstr(datestr(data_between_dates(1:2,1),'dd-mm-yyyy')) ,data_between_dates(1:2,2)}
where data_between_dates has a first column of datenum but I want to display date strings, then I get the following error:
Error using uitable Values within a cell array must be numeric, logical, or char
Error in uitable (line 52) thandle = builtin('uitable', varargin{:});
What's wrong? Thanks.
2 个评论
采纳的回答
Azzi Abdelmalek
2013-2-20
编辑:Azzi Abdelmalek
2013-2-20
Use
dates=cellstr(datestr(data_between_dates(1:2,1),'dd-mm-yyyy'))
data=num2cell(data_between_dates(1:2,2))
c=[dates data]
更多回答(1 个)
Jan
2013-2-20
c = {cellstr(...
This creates a cell, whose first element is a cell string, not a string, like:
c = {{'string'}, ...}
But UITABLE can handle strings only.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!