Last change
on this file since 17 was
17,
checked in by zhangj, 10 years ago
|
To have a stable version on the server.
|
-
Property svn:executable set to
*
|
File size:
781 bytes
|
Line | |
---|
1 | function resStr = idAuxNum2FileNameStr(num) |
---|
2 | %Encodes decimal number in string, which can then be used as a part of file name |
---|
3 | |
---|
4 | strParamValue = sprintf('%f', num); |
---|
5 | strParamValue = strrep(strParamValue, '.', '_'); |
---|
6 | lenOrigStrParamValue = length(strParamValue); |
---|
7 | numTrailZeros = 0; %removing trailing zeros |
---|
8 | for k = 1:lenOrigStrParamValue |
---|
9 | if(strcmp(strParamValue(lenOrigStrParamValue - k + 1), '0')) |
---|
10 | numTrailZeros = numTrailZeros + 1; |
---|
11 | else |
---|
12 | if(numTrailZeros > 0) && strcmp(strParamValue(lenOrigStrParamValue - k + 1), '_') |
---|
13 | numTrailZeros = numTrailZeros + 1; |
---|
14 | end |
---|
15 | break; |
---|
16 | end |
---|
17 | end |
---|
18 | if(numTrailZeros > 0) |
---|
19 | resStr = ''; |
---|
20 | for k = 1:lenOrigStrParamValue - numTrailZeros |
---|
21 | resStr = strcat(resStr, strParamValue(k)); |
---|
22 | end |
---|
23 | else |
---|
24 | resStr = strParamValue; |
---|
25 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.