The goal is to binarize an array after judging the threshold size
function [ y ] = filter_yuzhi( x,yuzhi )
% 过滤器 y为输出,x为数组输入,yuzhi为设定的阈值
% 根据yuzhi参数,判断当前的x, 如果x>yuzhi 输出1,否则输出0
a = length(x);
j = 1;
for i=1:a
if isnan(x(i))==0
if(x(i)>=yuzhi)
y(j) = 1;
else
y(j) = 0;
end
j = j+1;
end
end
end
Among them, if isnan(x(i))==0 is used to skip the NaN that may be contained in the array (mainly the empty place in the EXCEL table is NaN)