Revision 1dc429fc0da4cc5ff4f62617760447613f85980b authored by vbhandawat on 01 February 2021, 13:54:09 UTC, committed by GitHub on 01 February 2021, 13:54:09 UTC
1 parent 17f20a6
denoise.m
%This code allows quick denoising operation on a time series pulse data.
%Similar to low-pass filter.
%@Chanwoo Chun <cc2465@cornell.edu>
function y=denoise(a,n)
%n = mimimum number of consc. 1s that survive
index = [];
fs = find(conv(a,ones(1,n),'valid')==n);
fe = find(conv(fliplr(a),ones(1,n),'valid')==n);
if ~isempty(fs)
str=fs([true diff(fs)>n]);
ter = sort(length(a)+1-fe([true diff(fe)>n]));
index = cell2mat(arrayfun(@(s,e) (s:e), str, ter, 'UniformOutput', false));
end
a = zeros(1,length(a));
a(index) = 1;
y=a;

Computing file changes ...