different_proxy_whole = [];
for depth_num =1:length(proxies.adinos)
proxies.adinos(find(isnan(proxies.adinos)==1)) = 0;
proxies.hdinos(find(isnan(proxies.hdinos)==1)) = 0;
proxies.aother(find(isnan(proxies.aother)==1)) = 0; % 将nan换成0
proxy_max = max([proxies.hdinos(depth_num),proxies.adinos(depth_num),proxies.aother(depth_num)]);
proxy_min = min([proxies.hdinos(depth_num),proxies.adinos(depth_num),proxies.aother(depth_num)]);
new_combination = [proxies.hdinos(depth_num),proxies.adinos(depth_num),proxies.aother(depth_num)];
max_idx = find(new_combination==proxy_max);
min_idx = find(new_combination==proxy_min);
proxy_next_max = setdiff(new_combination, [max_idx(1) min_idx(1)]);
different_proxy = proxy_max - proxy_next_max; % 计算每个深度的优势藻种,用最大值减去次大值
different_proxy_whole = [different_proxy_whole,different_proxy];
end
将数组(double)中的nan值换成0,使用find
A(find(isnan(A)==1))=0;
找到数组中的某个值所在的位置:
idx=find(A==number);
如果是字符串则:
idx=find(strcmp(A, 'string' ));
剔除数组中指针所指的元素:
B=setdiff(A,[idx1,idx2]);