Changeset 6614
- Timestamp:
- 11/17/10 15:48:02 (14 years ago)
- Location:
- issm/trunk/src/m/utils/Array
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/utils/Array/find_string.m
r33 r6614 1 1 % 2 2 % function to find a string in a cell array 3 % (actually pretty close to matlab strmatch) 3 4 % 4 5 % [ifound]=find_string(cells,str) -
issm/trunk/src/m/utils/Array/str2int.m
r4027 r6614 1 1 % 2 % function to find and read the first integer in a character string. 2 % function to find and read the first or last positive integer 3 % in a character string. 3 4 % 4 % function [aint]=str2int(astr )5 % function [aint]=str2int(astr,cfl) 5 6 % 6 function [aint]=str2int(astr );7 function [aint]=str2int(astr,cfl); 7 8 8 9 aint=[]; 9 10 10 i=1; 11 while (i <= length(astr)) 12 if (astr(i) >= '0' && astr(i) <= '9') 13 aint=sscanf(astr(i:length(astr)),'%d',[1,1]); 14 break 15 else 16 i=i+1; 11 if ~exist('cfl','var') || strncmpi(cfl,'f',1) 12 i=1; 13 14 while (i <= length(astr)) 15 if (astr(i) >= '0' && astr(i) <= '9') 16 aint=sscanf(astr(i:length(astr)),'%d',[1,1]); 17 return 18 else 19 i=i+1; 20 end 17 21 end 22 23 elseif strncmpi(cfl,'l',1) 24 i=length(astr); 25 ifound=false; 26 27 while (i >= 1) 28 if (astr(i) >= '0' && astr(i) <= '9') 29 ifound=true; 30 i=i-1; 31 elseif ~ifound 32 i=i-1; 33 else 34 aint=sscanf(astr(i+1:length(astr)),'%d',[1,1]); 35 return 36 end 37 end 38 39 if ifound 40 aint=sscanf(astr,'%d',[1,1]); 41 return 42 end 18 43 end 19 44
Note:
See TracChangeset
for help on using the changeset viewer.