How to count the number of letter case changes in a string array
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
madhan ravi
2020-11-8
编辑:madhan ravi
2020-11-8
c = 'hfeHDdheD';
nnz(diff(ismember(c, 'A':'Z')))
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!