count number of elements in a cell
40 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Max
el 11 de Nov. de 2015
Comentada: Star Strider
el 11 de Nov. de 2015
say I have x={'zyryan';'zythem';'zythia';'zythum';'zyzomys'}
how would I count the number of elements in x. There are 5 words in x so I would like the output to be 1
1 comentario
Stephen23
el 11 de Nov. de 2015
Your example vector x has five elements (five cells), so where do you get the value 1 from?
Respuesta aceptada
Star Strider
el 11 de Nov. de 2015
I have no idea what result you want, but the size function will work:
x={'zyryan';'zythem';'zythia';'zythum';'zyzomys'};
sz_x = size(x)
sz_x =
5 1
2 comentarios
Star Strider
el 11 de Nov. de 2015
In that instance, the code becomes:
sz_x = length(x)
sz_x =
5
Más respuestas (1)
Stephen23
el 11 de Nov. de 2015
>> x={'zyryan';'zythem';'zythia';'zythum';'zyzomys'};
>> numel(x)
ans = 5
0 comentarios
Ver también
Categorías
Más información sobre Characters and Strings 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!