How to count the number of letter case changes in a string array

2 visualizaciones (últimos 30 días)
JARED VAHRENBERG
JARED VAHRENBERG el 8 de Nov. de 2020
Editada: madhan ravi el 8 de Nov. de 2020
If i had a string like 'hfeHDdheD' for example. The case changes 3 times. How would i get matlab to take any string and have it tell me how many case changes there are?
I thought maybe I could have it be into a logical array of upper and lower case but i'm not sure how to count when it changes from 0 to 1 and then 1 to 0

Respuestas (1)

madhan ravi
madhan ravi el 8 de Nov. de 2020
Editada: madhan ravi el 8 de Nov. de 2020
c = 'hfeHDdheD';
nnz(diff(ismember(c, 'A':'Z')))

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