source: MML/trunk/applications/orbit/lib/nam2indx.m @ 4

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 
1function [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
15s=size(names);      nmax=s(1);
16s=size(baselist);   nbase=s(1);
17
18num=0;
19indx=zeros(1,nmax);
20for 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
28end
29     
30if ~(num==nmax)
31disp('WARNING: not all names found in nam2indx');
32end
33
34if(num>1)
35  [i,j,indx] = find(indx);
36  indx=sort(indx(:));
37end
Note: See TracBrowser for help on using the repository browser.