• 大小: 67KB
    文件类型: .zip
    金币: 2
    下载: 0 次
    发布日期: 2024-02-02
  • 语言: Matlab
  • 标签: 压缩感知  

资源简介

压缩感知(Compressed Sensing, CS)matlab代码。实现多个正弦信号的随机欠采样,通过压缩感知恢复。两个m文件分别是两个算法,正交匹配追踪(OMP)算法和SPGL1算法(由E. van den Berg and M. P. Friedlander 提供)。

资源截图

代码片段和文件信息


%%%%%%%%%%%%% 若干频率正弦叠加信号 随机欠采样 压缩感知恢复(OMP算法) %%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%% 国防科学技术大学 杨俊刚 2011.03 %%%%%%%%%%%%%%%%%%%%

clear;

Tend=6; % 信号持续时间 0-Tend
fs=200; % 原始波形采样频率
tt1=0:1/fs:Tend; % 原始波形采样时间点
N=size(tt12); % 采样点数 
f1=13; % 正弦信号频率
f2=5;
f3=2;
y1=cos(2*pi*f1*tt1)+cos(2*pi*f2*tt1)+cos(2*pi*f3*tt1); % 波形

M=50;  % 随机欠采样信号的点数

%%%%%%%% 生成随机欠采样位置 %%%%%%%%%%%%%%%%
indexM=fix(rand(1M)*N); 
indexM=sort(indexM);
if (indexM(1)==0)
    indexM(1)=1;
end
 for kk=1:M-1
     while(indexM(kk+1)<=indexM(kk))
         indexM(kk+1)=indexM(kk+1)+1;
     end
 end
 %%%%%%%% 生成随机欠采样位置 end %%%%%%%%%%%%%%%%
 
 y2=y1(indexM); % 生成欠采样序列

DCT_Matrix=(dct(eye(N))).‘; % 生成稀疏变换矩阵 采用DCT矩阵

Sense=DCT_Matrix(indexM:); % 生成对应的测量矩阵

%%%%%%%% OMP 算法恢复
%%%%%%%% OMP start %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Aug=[];
corelate=zeros(1N);
rn=y2‘;
PHAI_cs=Sense;
yvec_cs=y2.‘;

K2=4; %恢复点数
for kk=1:K2
    corelate=PHAI_cs‘*rn;
    [vapos]=max(abs(corelate));
    Aug=[AugPHAI_cs(:pos)];
    PHAI_cs(:pos)=zeros(M1);
    phiy=((Aug‘)*Aug)^(-1)*Aug‘*yvec_cs;
    rn=yvec_cs-Aug*phiy;
    posarray(kk)=pos;
    waitbar(kk/K2);
end

recover_x=zeros(N1);
recover_x(posarray)=phiy; % 恢复的稀疏变换后的系数
%%%%%%%%OMP end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

recover_x1=DCT_Matrix*recover_x;  % 恢复原始信号

figure(1);plot((recover_x1));title(‘恢复信号‘);
figure(2);plot(y1);  title(‘原始信号‘);
figure(3);plot(y2);  title(‘随机欠采样信号‘);





 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-04-27 20:44  CS_Examples\
     文件        1557  2014-04-27 20:48  CS_Examples\CS_OMP.m
     文件        1220  2014-04-27 20:45  CS_Examples\CS_SPGL1.m
     目录           0  2014-04-27 11:46  CS_Examples\spgl1_1_7\
     文件        3861  2009-05-20 19:22  CS_Examples\spgl1_1_7\ChangeLog
     文件         697  2009-05-20 19:22  CS_Examples\spgl1_1_7\Contents.m
     文件       26436  2009-05-20 19:22  CS_Examples\spgl1_1_7\COPYING
     文件         184  2009-05-20 19:22  CS_Examples\spgl1_1_7\NormGroupL2_dual.m
     文件         176  2009-05-20 19:22  CS_Examples\spgl1_1_7\NormGroupL2_primal.m
     文件         375  2009-05-20 19:22  CS_Examples\spgl1_1_7\NormGroupL2_project.m
     文件         221  2009-05-20 19:22  CS_Examples\spgl1_1_7\NormL12_dual.m
     文件         209  2009-05-20 19:22  CS_Examples\spgl1_1_7\NormL12_primal.m
     文件         463  2009-05-20 19:22  CS_Examples\spgl1_1_7\NormL12_project.m
     文件          63  2009-05-20 19:22  CS_Examples\spgl1_1_7\NormL1_dual.m
     文件          63  2009-05-20 19:22  CS_Examples\spgl1_1_7\NormL1_primal.m
     文件         227  2009-05-20 19:22  CS_Examples\spgl1_1_7\NormL1_project.m
     目录           0  2014-04-27 11:46  CS_Examples\spgl1_1_7\private\
     文件        1561  2009-05-20 19:22  CS_Examples\spgl1_1_7\private\ensure.m
     文件        6398  2009-05-20 19:22  CS_Examples\spgl1_1_7\private\heap.c
     文件        3660  2009-05-20 19:22  CS_Examples\spgl1_1_7\private\heap.h
     文件       11849  2009-05-20 19:22  CS_Examples\spgl1_1_7\private\lsqr.m
     文件        2838  2009-05-20 19:22  CS_Examples\spgl1_1_7\private\oneProjector.m
     文件        5704  2009-05-20 19:22  CS_Examples\spgl1_1_7\private\oneProjectorCore.c
     文件        1485  2009-05-20 19:22  CS_Examples\spgl1_1_7\private\oneProjectorCore.h
     文件        4423  2009-05-20 19:22  CS_Examples\spgl1_1_7\private\oneProjectorMex.c
     文件        3797  2009-05-20 19:22  CS_Examples\spgl1_1_7\private\oneProjectorMex.m
     文件       10390  2009-05-20 19:22  CS_Examples\spgl1_1_7\private\oneProjectorMex.mexglx
     文件       17664  2009-05-20 19:22  CS_Examples\spgl1_1_7\private\oneProjectorMex.mexmaci
     文件        9216  2009-05-20 19:22  CS_Examples\spgl1_1_7\private\oneProjectorMex.mexw32
     文件        2783  2009-05-20 19:22  CS_Examples\spgl1_1_7\README
     文件       16195  2009-05-20 19:22  CS_Examples\spgl1_1_7\spgdemo.m
............此处省略8个文件信息

评论

共有 条评论