Skip to content

Commit

Permalink
added deadZone.m
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriele committed Mar 11, 2019
1 parent 8861aff commit e99e594
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions library/matlab-wbc/+wbc/deadZone.m
Original file line number Diff line number Diff line change
@@ -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: [email protected]
%
% Genoa, Dec 2018
%

%% --- Initialization ---

% initialize output
y = u;

for i = 1:length(u)

if abs(u(i)) < thr

y(i) = 0;
end
end
end

0 comments on commit e99e594

Please sign in to comment.