Last change
on this file since 743 was
353,
checked in by sommeria, 13 years ago
|
functions adapted to Matlab version 2009 (~ replaced by 'tild' in function output)
svn test put under 'try' (error observed)
fullfile_uvmat introduced, aimed at replacing name_generator
|
File size:
903 bytes
|
Rev | Line | |
---|
[8] | 1 | %'stra2num': transform letters (a, b, c) or numerical strings ('1','2'..) to the corresponding numbers
|
---|
| 2 | %--------------------------------------------
|
---|
| 3 | % function numres=stra2num(str)
|
---|
| 4 | %
|
---|
| 5 | % OUTPUT:
|
---|
| 6 | % numres: number (double)
|
---|
| 7 | %
|
---|
| 8 | % INPUT:
|
---|
| 9 | % str: string corresponding to a number or a letter 'a' 'b',.., otherwise the output is empty
|
---|
| 10 | %
|
---|
| 11 | % see also num2stra, name_generator, name2display
|
---|
| 12 |
|
---|
| 13 | function numres=stra2num(str)
|
---|
[353] | 14 | numres=[]; %default
|
---|
[8] | 15 | if double(str) >= 48 & double(str) <= 57 % = test for number strings
|
---|
[89] | 16 | numres=str2double(str);
|
---|
[8] | 17 | elseif double(str) >= 65 & double(str) <= 90 % test on ascii code for capital letters
|
---|
| 18 | numres=double(str)-64; %change capital letters to corresponding number in the alphabet
|
---|
| 19 | elseif double(str) >= 97 & double(str) <= 122 % test on ascii code for small letters
|
---|
| 20 | numres=double(str)-96; %change small letters to corresponding number in the alphabet
|
---|
| 21 | end
|
---|
Note: See
TracBrowser
for help on using the repository browser.