Extrac Part of a cell array

3 次查看(过去 30 天)
Daniel Boateng
Daniel Boateng 2019-5-28
回答: Stephen23 2019-5-28
I have a cell array like a = {'danny_820','richard_320','Tom_500','Fred_120'}. Please how do i extract the numbers so that i will be left with
{820,320,500,120}
Thanks

回答(1 个)

Stephen23
Stephen23 2019-5-28
>> a = {'danny_820','richard_320','Tom_500','Fred_120'};
>> str2double(regexp(a,'\d+$','once','match'))
ans =
820 320 500 120

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by