Can we sum lastletter of string?

1 vue (au cours des 30 derniers jours)
NGÔ LÝ NGUYÊN
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!

Réponse acceptée

Stephen23
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
  1 commentaire
NGÔ LÝ NGUYÊN
NGÔ LÝ NGUYÊN le 15 Fév 2020
thank you so much

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by