Borrar filtros
Borrar filtros

using uitable for mixed data

3 visualizaciones (últimos 30 días)
Stephen Thompson
Stephen Thompson el 13 de En. de 2017
Comentada: Walter Roberson el 13 de En. de 2017
I have a table of mixed type: 'word', 1, 5, 9 [multiple rows]
I want to create a table using uitable and get the error: While setting the 'Data' property of 'Table': Data must be a numeric, logical, or cell array
How do I display mixed data?

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de En. de 2017
data = {'word', 1, 5, 9; 'another', 7, 13, 21};
uitable('Data', data)
What would not be allowed is
data = {{'word', 1, 5, 9}; {'another', 7, 13, 21}}
That is, it is fine to use a cell array, but each entry inside the cell array must be a character vector or a numeric scalar or a logical (the new string data type is not supported either.). You are probably trying to use a cell array that has cell arrays in it.
  2 comentarios
Stephen Thompson
Stephen Thompson el 13 de En. de 2017
Editada: Stephen Thompson el 13 de En. de 2017
Indeed I was. I made the text into a character array, then made a cell array of that such that the cell array is of type:
[126x11 char] [126x1 double]
However now:
While setting the 'Data' property of 'Table': Data within a cell array must have size [1 1]
I guess because the dimensions don't match. What would be a valid way to store the text such that the dimensions remain 126X1.
Walter Roberson
Walter Roberson el 13 de En. de 2017
You need to break those parts into rows. You can use mat2cell for that
T = cellfun(@(M) mat2cell(M, ones(1, size(M,1)), size(M,2)), ThatCell, 'Uniform', 0);
data = [T{1}, T{2}];

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by