mp.m
来自「% Atomizer Main Directory, Version .802 」· M 代码 · 共 65 行
M
65 行
function coef = MP(x, NameOfDict, par1, par2, par3, natom, frac)
% MP.m -- Matching Pursuit
% Usage
% coef = MP(x, NameOfDict, par1, par2, par3[, natom, frac])
% Input
% x 1-d signal; n-by-1 column vector
% NameOfDict string; name of the dictionary
% par1,par2,par3 parameters of the dictionary
% natom max # of atoms desired, default = n
% frac min fraction total signal energy to enter, default=1e-2
%
% Use 'help dictionary' for dictionary objects: NameOfDict,par1,par2,par3
% Outputs
% coef coef of the MP representation; column vector
% Description
% 1. natom controls the maximum number of atoms MP can select
% 2. Selected atoms must have coefficients greater than a certain
% fraction of total signal energy, defined by the parameter
% frac, in order to be enter.
% See Also
% OMP, MP_Matrix, OMP_Matrix
%
x = x(:);
n = length(x);
if nargin < 7,
frac = 1e-2;
end
if nargin < 6,
natom = n;
end
[m L] = SizeOfDict(n, NameOfDict, par1, par2, par3);
zerosm = zeros(m,1);
nrm = norm(x);
amp = nrm;
residule = x;
coef = [];
index = [];
k = 0;
fprintf('\nMP:\n');
while (amp > frac*nrm) & (k < natom),
c = FastA(residule, NameOfDict, par1, par2, par3);
[amp i] = max(abs(c));
i = i(1);
index = [index; i];
coefnew = c(i);
coef = [coef; coefnew];
temp = zerosm; temp(i) = 1;
residule = residule - coefnew * FastS(temp, n, NameOfDict, par1, par2, par3);
k = k + 1;
disp(sprintf('Step%4g: select = %5g coef = %10.2e',k,i,coefnew));
end
h = length(coef);
coefbest = zeros(m, 1);
for i = 1:h,
coefbest(index(i)) = coefbest(index(i)) + coef(i);
end
coef = coefbest;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?