Can we sum lastletter of string?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
NGÔ LÝ NGUYÊN
le 15 Fév 2020
Commenté : NGÔ LÝ NGUYÊN
le 15 Fév 2020
i have data with
A = 111n22
B = 444m11
C = 777n55
I want select last letter of A B and C and then sum it. Pls help me!
0 commentaires
Réponse acceptée
Stephen23
le 15 Fév 2020
>> A = '111n22';
>> B = '444m11';
>> C = '777n55';
>> sum(str2double(regexp({A,B,C},'\d$','match','once'))) % single
ans = 8
Or perhaps:
>> sum(str2double(regexp({A,B,C},'\d+$','match','once'))) % multiple
ans = 88
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!