Datetime doesn't work in uitable

5 visualizaciones (últimos 30 días)
Douglas Anderson
Douglas Anderson el 14 de Oct. de 2021
Respondida: Walter Roberson el 14 de Oct. de 2021
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 comentario
Douglas Anderson
Douglas Anderson el 14 de Oct. de 2021
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);

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 14 de Oct. de 2021
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.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by