Uitable set problems

6 visualizaciones (últimos 30 días)
Petya Popova
Petya Popova el 12 de Jun. de 2012
Editada: cdr el 22 de Abr. de 2015
Hi everyone! I can't seem to populate my uitable. I want the first column to be names and the second and third numbers so i do the following:
char1=char(names);
dat={char1 acc sp};
set(handles.uitable1,'Data', dat, 'RowName',num);
,but i get the following error:
Data within a cell array must have size [1 1]
Please help what am i doing wrong? Ive tried setting the Column format to ''char'', but still no luck. Thanks in advance!

Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Jun. de 2012
dat={ cellstr(char1) num2cell(acc(:)) num2cell(sp(:)) };
  6 comentarios
Petya Popova
Petya Popova el 13 de Jun. de 2012
Hey Thanks that worked like a charm!And to answer your question I have to shamefully admit that I'm pretty new to matlab and programing at all.
I thought i needed the columns for the uitable, but i guess I don't really:)
I tried your suggestion, but I also use this to make a legend on the plot and it says it needs to be a string so I put cellstr(names), but then got error in cellstr itself...and it's all very confusing :D
But thanks you've been great help, I think that would work even though it's a bit heavy as I now realize :)
Walter Roberson
Walter Roberson el 13 de Jun. de 2012
When
names = {all.Name};
then to use those names as a legend, use
legend(names{:})

Iniciar sesión para comentar.

Más respuestas (1)

cdr
cdr el 22 de Abr. de 2015
Editada: cdr el 22 de Abr. de 2015
Solved the problem:
entered doubles via num2cell(double) and strings via cellstr.
[code] B(i)=cellstr(string1{i});
TE = [num2cell(double1') num2cell(double2) cellstr(B)'] [/code]
Thanks a lot!

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by