% Illustration of soft threshdolding
%
% Samuli Siltanen March 2017

% Choose threshold parameter mu
mu = 0.4;

% Create evaluation points
x = linspace(-1,1,512);

% Create hard and soft thresholding functions
th_h = x;
th_h(abs(x)<mu/2) = 0;
th_s = x;
th_s(abs(x)<mu/2) = 0;
th_s(x<=-mu/2) = th_s(x<=-mu/2)+mu/2;
th_s(x>=mu/2)  = th_s(x>=mu/2)-mu/2;


% Plot
figure(10)
clf
plot(x, th_h, 'b')
hold on 
plot(x, th_s, 'r')
axis equal

