压缩感知——OMP与CoSaMP算法的MATLAB实现

目录

  • OMP算法的MATLAB实现
  • CoSaMP算法的MATLAB实现
  • 完整代码及参考文献链接

OMP算法的MATLAB实现

function x_hat = OMP(A, y, k)
    
    [~, N] = size(A);
    
    % initialization
    x_hat = zeros(N, 1);
    r = y;
    Omega = [];
    
    % main loop
    for i = 1:k
        g = r.'*A;
        [~, j] = max(abs(g)./vecnorm(A));
        Omega = [Omega j];
        x_hat(Omega) = pinv(A(:, Omega))*y;
        r = y-A*x_hat;
    end
   
end

CoSaMP算法的MATLAB实现

function x_hat = CoSaMP(A, y, k)
    
    [~, N] = size(A);
    
    % initialization
%     x_hat = zeros(N, 1);
    r = y;
    T = [];
    
    % main loop
    iter_max = 10;
    iter_cnt = 0;
    
    while iter_cnt

完整代码及参考文献链接

OMP-CoSaMP.zip

你可能感兴趣的:(通信与信息论,matlab,算法)