Orthogonal matching pursuit

本文通过一个具体的MATLAB程序示例,详细介绍了正交匹配追踪(OMP)算法的实现过程。从初始化矩阵到迭代求解最小二乘问题,逐步展示了如何通过OMP算法找到稀疏解。该文适合对压缩感知和稀疏表示感兴趣的读者。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

帮别人做的问题:


自己写的程序:

% --------- The input ---------------
D = zeros(10, 10);
for ii=1:10,
    for jj=1:10,
        D(ii, jj) = sin(ii+jj);
    end
end
A = D + eye(10);

b = [-2 -6 -9 1 8 10 1 -9 -4 -3]';
S = 3;
% -----------------------------------
normA = normc(A);
residual = b;
len = size(A, 2);
index = zeros(len, 1);
for ii = 1:S,
    % Compute the inner product
    proj = normA'*residual;
    
    %find the max value and its index
    [~, pos] = max(abs(proj));
    
    % store the index
    index(ii) = pos(1);
    
    %solve the least squares problem
    a = pinv(A(:,index(1:ii)))*b;
    
    % compute the residual in the new dictionary
    residual = b-A(:, index(1:ii))*a;

end
x = zeros(length(b), 1);
x(index(1:ii)) = a;

% ------- the result ---------
norm(A*x-b)
norm(x)


参考:

【1】MP算法和OMP算法及其思想 http://blog.youkuaiyun.com/scucj/article/details/7467955

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值