Extracting number value from string from string using sscanf()
Show older comments
Hello
I have a problem trying to extract a number from a string looking like this
Seg_1169_Edgefun_1_5_2_15_90_30_3_1.000000e-001_5_1_1.000000e-001.tif
The number I am interested to extract is the 1169. Sometimes this number can be longer or shorter. The property I can use is that always there are 4 character before it 'Seg_'
I tried to work it out with the sscanf() but I didn't have any success. Do you have any recommendation ?
Thank you in advance
Accepted Answer
More Answers (1)
Jan
on 27 Aug 2012
The sscanf-method looks easy:
n = sscanf(s, 'Seg_%d');
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!