STRNUMERIC

Version 1.0.0.0 (1.65 KB) by Sww
Sorts a list of files (or strings) in a cell array based on numeric characters
217 Downloads
Updated 7 Jan 2014

View License

STRNUMERIC sorts a cell array of strings in numeric order based on numbers embedded within each string.

Example:

>> str = {'Test.txt'
'Test_4_Case_1_Day_10_34.txt'
'Test_3_Case_1_Day_10_34.txt'
'Test_2_Case_1_Day_9.txt'
'Test_2_Case_1_Day_10_34.txt'
'Test_2_Case_001_Day_10_234.txt'
'Test_2_Case_001_Day_10.txt'
'Test_1_Case_33_Day_1.txt'};

>> strnumeric(str)

ans =

'Test.txt'
'Test_1_Case_33_Day_1.txt'
'Test_2_Case_1_Day_9.txt'
'Test_2_Case_001_Day_10.txt'
'Test_2_Case_1_Day_10_34.txt'
'Test_2_Case_001_Day_10_234.txt'
'Test_3_Case_1_Day_10_34.txt'
'Test_4_Case_1_Day_10_34.txt'

Cite As

Sww (2024). STRNUMERIC (https://www.mathworks.com/matlabcentral/fileexchange/44968-strnumeric), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Cell Arrays in Help Center and MATLAB Answers
Acknowledgements

Inspired: SOLLAR CHIMNEY DISALINATION APPARATUS

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.0.0.0