function  stateIndex = name2index(stateAb)
% stateIndex is the index number of the state name abbreviation stateAb.
% E.g., the index value 2 is returned if stateAb is 'AK'.
% See the state name abbreviation array below.

states=[ ...
'AL';'AK';'AZ';'AR';'CA';'CO';'CT';'DE';'FL';'GA';'HI';'ID';'IL';'IN'; ...
'IA';'KS';'KY';'LA';'ME';'MD';'MA';'MI';'MN';'MS';'MO';'MT';'NE';'NV'; ...
'NH';'NJ';'NM';'NY';'NC';'ND';'OH';'OK';'OR';'PA';'RI';'SC';'SD';'TN'; ...
'TX';'UT';'VT';'VA';'WA';'WV';'WI';'WY';];

[nr,nc]= size(states);
stateIndex= 1;
while  stateIndex<=nr && ~strcmp(states(stateIndex,:), stateAb)
    stateIndex= stateIndex + 1;
end
if stateIndex>nr  % stateAb not found
    error('Must use proper state name abbreviation.')
end
