Can we sum lastletter of string?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
NGÔ LÝ NGUYÊN
el 15 de Feb. de 2020
Comentada: NGÔ LÝ NGUYÊN
el 15 de Feb. de 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 comentarios
Respuesta aceptada
Stephen23
el 15 de Feb. de 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
Más respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings 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!