Borrar filtros
Borrar filtros

Removing an empty 1st row from a UITABLE (cell array)

3 visualizaciones (últimos 30 días)
Jason
Jason el 5 de Feb. de 2020
Editada: Bhaskar R el 5 de Feb. de 2020
Hi. I have a uitable that I append to and sometime I have an empty 1st row like this:
d=get(handles.uitable1, 'data')
d =
2×6 cell array
{0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}
{[ 0]} {[ 1798.46]} {[ 1659.30]} {[ 1621.38]} {[ 1521.24]} {[ 57.67]}
Whats the best way to check for this and delete if empty
BTW, its sometimes has an empty 1st row, because sometimes I clear the old data out (that can have more columns than my 6 here) and use the following to reset it:
set(handles.uitable1, 'Data', cell(1,6))
But this leaves
{0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}

Respuesta aceptada

Bhaskar R
Bhaskar R el 5 de Feb. de 2020
d = d(~cellfun(@isempty, d))';
  5 comentarios
Bhaskar R
Bhaskar R el 5 de Feb. de 2020
Editada: Bhaskar R el 5 de Feb. de 2020
If you want to remove first row of the d
d(1,:) = [];
If you want to remove any row which contains any empty cell
d = d(any(~cellfun(@isempty, d), 2), :);
Jason
Jason el 5 de Feb. de 2020
Perfect, thankyou

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Scope Variables and Generate Names 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