annotate toolboxes/FullBNT-1.0.7/KPMtools/asdemo.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 % ASORT
wolffd@0 2 % a pedestrian NUMERICAL SORTER of ALPHANUMERIC data
wolffd@0 3
wolffd@0 4 % - create some data
wolffd@0 5 d = {
wolffd@0 6 % strings with one valid alphanumeric number
wolffd@0 7 % sorted numerically
wolffd@0 8 '-inf'
wolffd@0 9 'x-3.2e4y'
wolffd@0 10 'f-1.4'
wolffd@0 11 '-.1'
wolffd@0 12 '+ .1d-2'
wolffd@0 13 '.1'
wolffd@0 14 'f.1'
wolffd@0 15 'f -+1.4'
wolffd@0 16 'f.2'
wolffd@0 17 'f.3'
wolffd@0 18 'f.10'
wolffd@0 19 'f.11'
wolffd@0 20 '+inf'
wolffd@0 21 ' -nan'
wolffd@0 22 '+ nan'
wolffd@0 23 'nan'
wolffd@0 24 % strings with many numbers or invalid/ambiguous numbers
wolffd@0 25 % sorted in ascii dictionary order
wolffd@0 26 ' nan nan'
wolffd@0 27 '+ .1e-.2'
wolffd@0 28 '-1 2'
wolffd@0 29 'Z12e12ez'
wolffd@0 30 'inf -inf'
wolffd@0 31 's.3TT.4'
wolffd@0 32 'z12e12ez'
wolffd@0 33 % strings without numbers
wolffd@0 34 % sorted in ascii dictionary order
wolffd@0 35 ' . .. '
wolffd@0 36 '.'
wolffd@0 37 '...'
wolffd@0 38 '.b a.'
wolffd@0 39 'a string'
wolffd@0 40 'a. .b'
wolffd@0 41 };
wolffd@0 42 % ... and scramble it...
wolffd@0 43 rand('seed',10);
wolffd@0 44 d=d(randperm(numel(d)));
wolffd@0 45
wolffd@0 46 % - run ASORT with
wolffd@0 47 % verbose output: <-v>
wolffd@0 48 % keep additional results: <-d>
wolffd@0 49 o=asort(d,'-v','-d');
wolffd@0 50 % - or
wolffd@0 51 % p=asort(char(d),'-v','-d');
wolffd@0 52
wolffd@0 53 % - show results
wolffd@0 54 o
wolffd@0 55 o.anr
wolffd@0 56
wolffd@0 57 % - run ASORT with no-space/template options
wolffd@0 58 % NOTE the impact of -w/-t order!
wolffd@0 59 s={'ff - 1','ff + 1','- 12'};
wolffd@0 60 % RAW
wolffd@0 61 o=asort(s,'-v');
wolffd@0 62 % remove SPACEs
wolffd@0 63 o=asort(s,'-v','-w');
wolffd@0 64 % remove TEMPLATE(s)
wolffd@0 65 o=asort(s,'-v','-t',{'ff','1'});
wolffd@0 66 % remove TEMPLATE(s) than SPACEs
wolffd@0 67 o=asort(s,'-v','-t','1','-w');
wolffd@0 68 % remove SPACEs than TEMPLATE(s)
wolffd@0 69 o=asort(s,'-v','-w','-t','1');
wolffd@0 70