strtoseq¶
strtoseq converts a string with a description for a sequence to an integer vector.
- rvSequence = strtoseq(ssSequence, rsMin, rsMax)
Return Value
rvSequence is an integer vector or the value rsMin-1, if an error occurred.
Parameters
- svSequence
svSequence is a string with a sequence definition. The elements are separated by a comma (,). A range of elements is separated by a dash (-). A range of elements with an increment greater than 1 contains three numbers separated by a colon (2:2:10) will create the sequence “2,4,6,8,10”. Negative values count from the end. -1 is the last value (rsMax), -2 is rsMax-1. The string “-10–1” will create a vector with the last 10 elements.
- rsMin
rsMin is the lower limit of valid values.
- rsMax
rsMax is the upper limit of valid values.
Example
* create_sequence("1:10",1,20)
1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00
* create_sequence("1:12",1,20)
1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00
* create_sequence("1:12,16",1,20)
1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 16.00
* create_sequence("1:12,16,-2",1,20)
1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 16.00 19.00
* create_sequence("1:5,16,-2",1,20)
1.00 2.00 3.00 4.00 5.00 16.00 19.00
* create_sequence("-6--1",1,20)
15.00 16.00 17.00 18.00 19.00 20.00
* create_sequence("1,6,9",1,20)
1.00 6.00 9.00
See also
id-41452