This repository has been archived by the owner on Dec 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
select_01.m
59 lines (49 loc) · 1.67 KB
/
select_01.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
%% select_01
% finds booleans for occurences of members of taxon among members of taxon_src
%
function [sel taxa_src] = select_01(taxon_src, taxon_sel)
% created 2016/04/12 by Bas Kooijman, modified 2017/06/14
%% Syntax
% [sel taxa_src] = <select_01.m *select_01*>(taxon_src, taxon_sel)
%% Description
% Finds booleans for occurences of members of taxon among members of taxon_src
%
% Input
%
% * taxon_src: optional character string with name of source taxon (default 'Animalia')
% * taxon_sel: character or cell string with names of taxa that belong to source taxon
%
% Output
%
% * sel: n-vector with booleans
% * taxa_scr: n-vector with names of members of taxon_src
%% Remarks
% The names of members of taxon can be found by
% [sel nm] = select_01(taxon_src, taxon); nm(sel)
%% Example of use
% sel = select_01('Aves'); or sel = select_01({'Aves','Mammalia'); or
% sel = select_01('Animalia',{'Aves','Mammalia'});
%
% sel_fish = select_01('Vertebrata') & ~select_01('Tetrapoda');
% or
% sel_fish = select_01({'Myxini','Cephalaspidomorphi','Chondrichthyes','Actinopterygii','Sarcopterygii'})
if ~exist('taxon_src', 'var') && ~exist('taxon_sel', 'var')
taxon_sel = 'Animalia'; taxon_src = 'Animalia';
elseif ~exist('taxon_sel', 'var')
taxon_sel = taxon_src; taxon_src = 'Animalia';
end
taxa_src = select(taxon_src); n_taxa_src = size(taxa_src,1);
sel = false(n_taxa_src,1);
if ~iscell(taxon_sel)
taxa = select(taxon_sel); n_taxa = size(taxa,1);
for i = 1:n_taxa
sel(strcmp(taxa_src, taxa{i})) = true;
end
else
for j = 1:length(taxon_sel)
taxa = select(taxon_sel{j}); n_taxa = size(taxa,1);
for i = 1:n_taxa
sel(strcmp(taxa_src, taxa{i})) = true;
end
end
end