필터 지우기
필터 지우기

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 CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by