I have file names 'Shot 12 Spectra data.mat' (many files where just the number varies). I want to select just the number from the file name. How do I do this please?

 채택된 답변

Star Strider
Star Strider 2018년 3월 28일
편집: Star Strider 2018년 3월 28일

0 개 추천

Try this:
str = 'Shot 12 Spectra data.mat';
Nr = sscanf(str, '%*s%d')
Nr =
12
EDIT
If the file names are in a cell array:
cel = {'Shot 12 Spectra data.mat'; 'Shot 13 Spectra data.mat'};
Nr = cellfun(@(x)sscanf(x, '%*s%d'), cel)
Nr =
12
13

댓글 수: 2

D F
D F 2018년 3월 28일
Thanks!
Star Strider
Star Strider 2018년 3월 28일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Specialized Power Systems에 대해 자세히 알아보기

태그

질문:

D F
2018년 3월 28일

댓글:

2018년 3월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by