Skip to content

Instantly share code, notes, and snippets.

@Kubuxu
Created July 6, 2019 16:00
Show Gist options
  • Save Kubuxu/5c58022d7af6b1f3dfb66f0eae5a730c to your computer and use it in GitHub Desktop.
Save Kubuxu/5c58022d7af6b1f3dfb66f0eae5a730c to your computer and use it in GitHub Desktop.
N = 600;
x = 1:N;
mean = 61;
scale = 3;
noisy = random('Rayleigh', scale, 1, N) + mean;
drop = 0.5/100; % packet drop chance
for i = x
if drop > rand()
noisy(i) = 3*noisy(i);
end
end
alpha = 0.5;
b = alpha;
a = [1, -(1-alpha)];
filtered5= filter(b, a, noisy);
alpha = 0.1;
b = alpha;
a = [1, -(1-alpha)];
filtered1= filter(b, a, noisy);
plot(x, noisy, '-b', x, filtered5, '-r', x, filtered1, '-g');
legend('input', 'filter a=0.5', 'filter a=0.1')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment