-
Notifications
You must be signed in to change notification settings - Fork 5
/
HGSid.m
76 lines (61 loc) · 1.68 KB
/
HGSid.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
function [id] = HGSid(species)
%**************************************************************************
%
% [id] = HGSid(species)
%
%**************************************************************************
%
% HGSid finds the id of the species to improve the velocity of the code
%
%**************************************************************************
% Inputs:
%--------------------------------------------------------------------------
% species --> String or numbers of species
%
% Outputs:
%--------------------------------------------------------------------------
% id --> Species id
%
%**************************************************************************
% *HGS 2.1
% *By Caleb Fuster, Manel Soria and Arnau Miró
% *ESEIAAT UPC
if isnumeric(species)
id=species;
return
end
global HGSdata;HGSload;
ns=size(HGSdata.Mm,1); % Number of species
if isfield(HGSdata,'comb') && ~isempty(HGSdata.comb)
combination = 1;
else
combination = 0;
end
if iscell(species)
id = zeros(1,length(species));
for ii = 1:length(species)
id(ii) = find1(species{ii});
end
return
end
if ischar(species)
id = find1(species);
return
end
function id = find1(name)
search = ismember(HGSdata.name(:),name);
if combination
search1 = ismember(HGSdata.comb(:),name);
else
search1 = 0;
end
if all(search == 0) && all(search1 == 0)
error('HGSid: %s not found in the data base\n',name);
elseif ~all(search == 0)
id = find(search);
else
id = ns + find(search1);
end
end
error('uhh ? HGSid wrong data type');
end