Colon operation for numerical string(s)/Print page selection

Parse numerical strings/string with delimiter to a concatenated numerical vector
96 Downloads
Updated 15 Apr 2015

View License

Parse numerical strings cell array or string with delimiter to a concatenated numerical vector with equal space for each numerical range. What it does is basically the colon operation for strings with concatenation. It is useful for GUI design as per user input or converting data from text file input. All the COLON operation rules apply to this function.
Examples:
numstr2range('1-10') % The output is equivalent to 1:10
numstr2range('1-5,7,9-10') % The output is equivalent to [1:5,7,9:10]. Very much like the print page selection.
numstr2range('1-10','space',0.1) % The output is equivalent to 1:0.1:10
numstr2range('1-10,11-20','space',0.1) % The output is equivalent to [1:0.1:10 11:0.1:20]
numstr2range({'1-10','101-110','50-51,80'},'space',0.1); % The output is equivalent to [1:0.1:10 101:0.1:110 50:0.1:51 80];
numstr2range('1-10,8-12,15-16','space',0.1); % The output is equivalent to [1:0.1:10 8:0.1:12 15:0.1:16];
numstr2range('1-10,8-12,15-16','duplicated',false); % The output is equivalent to unique([1:10 8:12 15:16]);
numstr2range('2-5,1-4','sortoption','descend') % The output is equivalent to sort([2:5 1:4],'descend')

Cite As

Yung-Yeh Chang (2024). Colon operation for numerical string(s)/Print page selection (https://www.mathworks.com/matlabcentral/fileexchange/50504-colon-operation-for-numerical-string-s-print-page-selection), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.1.0.0

Update description.

1.0.0.0