⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sparsesiggen4plusnoise.m

📁 一种新的稀疏问题的直接求解算法——平滑l0算法
💻 M
字号:
function [s,idxNZ] = sparseSigGen4plusNoise(N,NZ,sigma_off,fixedActiveValue)
% - Generates an Nx1 random sparse vector with "N-NZ" number of its components 
%   (randomly) chosen to be nearly zero (inactive components). That is NZ is
%   the number of Non-Zero (active) components.
% - The rest of the compoents will have the fixed value "fixedActiveValue" 
%   active components). If not supplied with the "fixedActiveValue", the
%   function generates a gaussian noise with unit varinace over the active
%   components.
% - The "sigma_off" parameter controls the variance of (gaussian) noise over the
%   inactive components.
% - The function also returns the indices of the Non-zero (i.e., active)
%   components.
if nargin < 2
    NZ = 0.1*N;
end

if nargin < 3
    sigma_off = 0.01;
end

idxNZ = zeros(N,1);
rndPerm = randperm(N);
idxNZ(rndPerm(1:NZ)) = 1;
idxNZ = logical(idxNZ);

s = zeros(N,1);
if nargin < 4
    s(idxNZ) = randn(NZ,1);
else
    s(idxNZ) = fixedActiveValue;
end
s(~idxNZ) = sigma_off*randn(N-NZ,1);

% s = filter(1,[1,-0.2],s);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -