Datetime doesn't work in uitable
4 ビュー (過去 30 日間)
I input several cell arrays to a uitable that I would like to be able to sort. The other cell arrays are numeric or strings, but if I include the datetime cell array I get the following error:
Error using matlab.ui.control.Table/set
Error setting property 'Data' of class 'Table':
Values within a cell array must be numeric, logical, or char
Error in va2_17>shot_wizard_button_Callback (line 247)
I suppose I could separate the datetime into date and time, but then couldn't sort, right? Any thoughts?
Walter Roberson 2021 年 10 月 14 日
Your reference to handles.file_table tells us that you are using GUIDE and "traditional figures". And in traditional figures, uitable() does not support datatime values.
If you use an ISO format such as uuuuMMdd HH:mm:ss and string() the result, then what you get can be sorted. But keep in mind that uitable() in traditional figures do not offer sort operations themselves. The ability to click on a header to sort is offered only for uitable within uifigure()... which I believe do support datetime elements.