% mtvd_demo1: Moreau-enhanced Total Variation denoising (MTVD)
%
% Ivan Selesnick
% 2016

clear

y = load('blocks_noisy.txt');   % load data

lam = 2;       % lam should be positive (smoothing parameter)
gamma = 0.7;   % gamma should be between 0 and 1 (convexity parameter)
Nit = 20;      % Nit should be a positive integer (number of iterations)

x = mtvd(y, lam, gamma, Nit);

% x = mtvd(y, lam, gamma, Nit, 'plots');  % Display plot each iteration

figure(1)
clf

subplot(2, 1, 1)
plot(y)
title('Noisy signal');
ax = [0 length(y) -3 6];
axis(ax)

subplot(2, 1, 2)
plot(x)
title('Moreau-enhanced Total Variation Denoising (gamma = 0.7)');
axis(ax)

print -dpdf mtvd_demo1

