From e99e5948cab18306f2f5e8a81a23e9eba9ced500 Mon Sep 17 00:00:00 2001 From: Gabriele Date: Mon, 11 Mar 2019 14:11:37 +0100 Subject: [PATCH] added deadZone.m --- library/matlab-wbc/+wbc/deadZone.m | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 library/matlab-wbc/+wbc/deadZone.m diff --git a/library/matlab-wbc/+wbc/deadZone.m b/library/matlab-wbc/+wbc/deadZone.m new file mode 100644 index 0000000..75ef56b --- /dev/null +++ b/library/matlab-wbc/+wbc/deadZone.m @@ -0,0 +1,35 @@ +function y = deadZone(u, thr) + + % DEADZONE implements a dead zone for the input u. If an element of u is + % lower (absolute value) than a user-defined threshold, + % consider that element of u as zero. u can be either a vector + % or a scalar. + % + % FORMAT: y = deadZone(u, thr) + % + % INPUT: - u = [n * 1] input vector; + % - thr = user-defined threshold; + % + % OUTPUT: - y = [n * 1] filtered output. + % + % Authors: Daniele Pucci, Marie Charbonneau, Gabriele Nava + % + % all authors are with the Italian Istitute of Technology (IIT) + % email: name.surname@iit.it + % + % Genoa, Dec 2018 + % + + %% --- Initialization --- + + % initialize output + y = u; + + for i = 1:length(u) + + if abs(u(i)) < thr + + y(i) = 0; + end + end +end \ No newline at end of file