Trying to input data into uitable, but getting error: Data must be a numeric, logical, or cell array
30 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
So, I've been reading through documentation for about an hour now, and I can't seem to figure this out.
I've created a UItable that needs to be filled. I've also created a table of data that I've imported from an excel file as a cell.
When I try to fill in the UItable with the data however, it gives me the error:
While setting the 'Data' property of 'Table':
Values within a cell array must be numeric, logical, or char
I cannot, for the life of me figure this out and I've been at this all day.
Here is the only other information I can give that might be useful: assuming the cell array is named "A":
class(A) = cell
A = {24x1 cell} {24x1 cell} {24x1 cell} {24x1 cell} {24x1 cell}
I've tried to convert these to characters or other such things, but nothing is seeming to work.
Any advice would really be appreciated!
1 Kommentar
marlon hernandez
am 2 Mär. 2019
talves esto pueda ayudarte, yo estoy trabajando con MYSQL y envio una tabla a matlab para visualizarla en GUIDE en un panel, tenia el mismo error y lo unico que hice fue esto convertirla a cell de esta forma "C= table2cell(datadb)" siendo datadb la table que deseaba poner en la tabla del GUIDE
:
prefs = setdbprefs('DataReturnFormat');
setdbprefs('DataReturnFormat','table'
%% Make connection to database
conn = database('datosbase','root','');
%% Execute query and fetch results
curs = exec(conn,['SELECT * ' ...
'FROM atletas.paciente']);
curs = fetch(curs);
datadb = curs.Data
C = table2cell(datadb)
set(handles.uitable1,'data',C);
close(curs)
suerte
Antworten (1)
Niels
am 27 Jan. 2017
Bearbeitet: Niels
am 27 Jan. 2017
i copied this from the uitable documentation:
d = {'Male',52,true;'Male',40,true;'Female',25,false};
t.Data = d;
t.Position = [20 20 258 78];
as you can see the data has to be a cell array, but the contents of this cell array are not
in your example (i guess A shall be the data you want to put into the table) the contents are cell arrays as well
example:
A={[1 2] a {100} [true false]}
A =
1×4 cell array
[1×2 double] 'hello world' {1×1 cell} [1×2 logical]
everything above, except the cell arrays, would be fine.
my guess is you cant save your data in single matrix since the data are no numbers, so you saved them in a cell array and cant use
t.data={A}; % and you shouldnt cause your data is alrdy a cell array
as shown in the example the data in the table will be saved in 1 cell array (in your case a 25x5)
since you saved your data in several cell arrays you can proceed as follows:
put one cell array of yours after another so that you get 1 25x5 cell array
formated_data=[A{1},A{2},A{3},A{4},A{5}];
t.Data=formated_data;
0 Kommentare
Siehe auch
Kategorien
Mehr zu Whos finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!