Last change
on this file since 4 was
4,
checked in by zhangj, 10 years ago
|
Initial import--MML version from SOLEIL@2013
|
File size:
950 bytes
|
Line | |
---|
1 | function [num,indx]=nam2indx(baselist,names) |
---|
2 | %[num,indx]=nam2indx(baselist,names) |
---|
3 | % baselist=baseline list of names to check against |
---|
4 | % names=names to check against baseline list |
---|
5 | % num,indx=indices of 'names' as found in 'baselist' |
---|
6 | %NOTE: names string must be same number of characters as baselist (excluding blanks) |
---|
7 | %NOTE: if you call nam2indx with the same parameter |
---|
8 | % in the 'num' field as in the 'indx' field - kk stops at 32 |
---|
9 | |
---|
10 | % if ~(length(baselist(1,:))==length(names(1,:))) |
---|
11 | % disp('WARNING: string lengths differ in nam2indx'); |
---|
12 | % return |
---|
13 | % end |
---|
14 | |
---|
15 | s=size(names); nmax=s(1); |
---|
16 | s=size(baselist); nbase=s(1); |
---|
17 | |
---|
18 | num=0; |
---|
19 | indx=zeros(1,nmax); |
---|
20 | for jj=1:nmax |
---|
21 | for kk=1:nbase |
---|
22 | if strcmp(deblank(baselist(kk,:)),deblank(names(jj,:)))==1; |
---|
23 | num=num+1; |
---|
24 | indx(num)=kk; |
---|
25 | break; |
---|
26 | end |
---|
27 | end |
---|
28 | end |
---|
29 | |
---|
30 | if ~(num==nmax) |
---|
31 | disp('WARNING: not all names found in nam2indx'); |
---|
32 | end |
---|
33 | |
---|
34 | if(num>1) |
---|
35 | [i,j,indx] = find(indx); |
---|
36 | indx=sort(indx(:)); |
---|
37 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.