Skip to content

Instantly share code, notes, and snippets.

@ferryzhou
Created April 16, 2012 18:19
Show Gist options
  • Save ferryzhou/2400481 to your computer and use it in GitHub Desktop.
Save ferryzhou/2400481 to your computer and use it in GitHub Desktop.
Automatically generate a threshold for a vector. Can be used to filter out noise.
function t = get_threshold(v)
% pitch the lowest 20%
[m, inds] = sort(v);
P = fix(0.2 * length(v));
nt = m(P);
P = fix(0.8 * length(v));
nt2 = m(P);
t = nt + 0.3 * (nt2 - nt);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment