Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear; close all; clc;
- load data_l1_trend_filtering.mat;
- N = length(yti);
- % your solution here %
- figure();
- plot(yti); hold on
- %% variables
- % Creating A
- A= zeros(N-1, N);
- for i = 1:N-1
- A(i, i)=-1;
- A(i, i+1) = 1;
- end
- %creating gamma
- gamma = 5;
- gammas = linspace(1, 40, 20);
- trade_off = zeros(2, 20);
- %% CVX
- for gamma = 1 : size(gammas, 2)
- cvx_begin
- variable x_head(N);
- %minimize( sqrt( (yti - x_head)'*(yti - x_head) ) + gamma * sqrt( (A*x_head)'*(A*x_head) ) );
- %minimize( (yti - x_head)'*(yti - x_head) + gamma * (A*x_head)'*(A*x_head) );
- minimize( norm( (yti - x_head) ) + gamma * norm( (A*x_head) ) );
- cvx_end
- trade_off(1, gamma) = norm( (A*x_head) );
- trade_off(2, gamma) = norm( (yti - x_head) );
- end
- figure();
- plot(trade_off(2, :),trade_off(1, :) );
Add Comment
Please, Sign In to add comment