フィルターのクリア

Datetime doesn't work in uitable

3 ビュー (過去 30 日間)
Douglas Anderson
Douglas Anderson 2021 年 10 月 14 日
回答済み: Walter Roberson 2021 年 10 月 14 日
Hello,
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)
set(handles.file_table,'Data',the_data2);
I suppose I could separate the datetime into date and time, but then couldn't sort, right? Any thoughts?
Thanks.
Doug
  1 件のコメント
Douglas Anderson
Douglas Anderson 2021 年 10 月 14 日
FYI, here is the code
% Load table
serial_numbers = struc_file.serial_number;
file_names = struc_file.file_name;
date_time = struc_file.event_date_time;
ppv = struc_file.ppv;
% Fix Serial Number format, removing Carriage Return
for n = 1:length(serial_numbers)
sss = serial_numbers{n};
ss2 = sss(1:4);
serial_numbers{n} = ss2;
end
% The following works without date_time
the_data2 = [serial_numbers,file_names,date_time,ppv]; %date_time,ppv];
set(handles.file_table,'Data',the_data2);

サインインしてコメントする。

採用された回答

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by