How does one count the characters in an array?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jay
el 11 de Abr. de 2016
Comentada: Jay
el 17 de Abr. de 2016
How do I obtain an arrays character count?
Eg. Value = 1111
I want the character count output to be 4
1 comentario
Walter Roberson
el 11 de Abr. de 2016
Is that
Value = 1111
or is it
Value = '1111'
If it is numeric, then how do you want to process negative numbers, and how do you want to process numbers with fractional part, and how do you want to process numbers that would typically be expressed in scientific notation?
Respuesta aceptada
Más respuestas (2)
Andrei Bobrov
el 11 de Abr. de 2016
Editada: Andrei Bobrov
el 11 de Abr. de 2016
If your Value is numeric type, then:
out = floor(log10(Value)+1);
if Value is char type then:
out = numel(Value - '0');
1 comentario
Jay
el 11 de Abr. de 2016
Editada: Jay
el 11 de Abr. de 2016
4 comentarios
Walter Roberson
el 13 de Abr. de 2016
Edit boxes do not have a Value. Edit boxes have a String.
S = get(handles.edit1, 'String');
length(S)
Ver también
Categorías
Más información sobre Interactive Control and Callbacks 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!