Convert coordinate direction string(s) to number(s).
x=imat_dir2num(dir)
IMAT_DIR2NUM is a utility function that converts direction strings to numeric direction codes.
The direction string dir can be either a single string (in which case IMAT_DIR2NUM will return a scalar code); or a cell array of strings (in which case IMAT_DIR2NUM will return a numeric array); or an nxm character array, with m<=4 (in which case IMAT_DIR2NUM will return an nx1 numeric array).
The numeric code returned by IMAT_DIR2NUM for each direction string is given in the following table.
Numeric code | Direction | Numeric code | Direction |
1 | X+ | -1 | X- |
2 | Y+ | -2 | Y- |
3 | Z+ | -3 | Z- |
4 | RX+ | -4 | RX- |
5 | RY+ | -5 | RY- |
6 | RZ+ | -6 | RZ- |
0 | any other |
>> imat_dir2num('RX-')
ans =
-4
>> t=imat_ctrace('5y', '3rx', '3z', '4x-', '3z', '5y+')
t =
'5Y+'
'3RX+'
'3Z+'
'4X-'
'3Z+'
'5Y+'
>> d=dir(t)
d =
'Y+'
'RX+'
'Z+'
'X-'
'Z+'
'Y+'
>> imat_dir2num(d)
ans =
2
4
3
-1
3
2
>>