필터 지우기
필터 지우기

Locating number from file name

조회 수: 3 (최근 30일)
D F
D F 2018년 3월 28일
댓글: Star Strider 2018년 3월 28일
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일
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개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by