Extract number from data file name

조회 수: 2 (최근 30일)
Win co
Win co 2013년 9월 26일
댓글: Win co 2013년 9월 26일
Hi, I have a list of data file name below :
Data_T2_31_4c_comb_1_9-10-11-12.mat
Data_T2_31_4c_comb_2_9-10-11-13.mat
...
Data_T2_31_4c_comb_3876_25-26-27-28.mat
I would like to extract the number in the 20th character, so that I will have a list of increasing integers [1 2 .. 3876]. Could you show me how to do that please ! Winn

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 26일
편집: Azzi Abdelmalek 2013년 9월 26일
s={'Data_T2_31_4c_comb_1_9-10-11-12.mat'
'Data_T2_31_4c_comb_2_9-10-11-13.mat'}
out=regexp(s,'\d+','match')
out=str2double(cat(1,out{:}))
  댓글 수: 1
Win co
Win co 2013년 9월 26일
works like charm. Great thank !

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by