I am interested to plot the L0-norm
penalty function in matlab.
In fact, I know that the L0-norm
of a vector x, ||x||_0, returns a value which designates the total number of nonzero elements in x. In other terms, ||x||_0 = #(i | xi !=0).
For example, for the L1-norm of x, it returns the sum of the absolute values of the elements in x. The matlab code to plot the L_1 norm penalty function is:
clear all;
clc;
x = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5];
penal = zeros (length(x),1);
lambda = 2; % the tuning parameter
for ii = 1 : length(x)
penal(ii) = lambda*abs(x(ii));
end
figure
plot(x(:), penal(:), 'r');
But now what about the L_0 norm??
Any help will be very appreciated!