clc
clear
close all
% 1-D信号压缩传感的实现(正交匹配追踪法Orthogonal Matching Pursuit)
% 测量数M>=K*log(N/K),K是稀疏度,N信号长度,可以近乎完全重构
% input signal x
% measurement vector s
% 待重构的谱域(变换域)向量hat_y
% 重构得到时域信号hat_x
%% 1. 时域测试信号生成
K=7; % 稀疏度(做FFT可以看出来)
N=256; % 信号长度
M=64; % 测量数(M>=K*log(N/K),至少40,但有出错的概率)
f1=50; % 信号频率1
f2=100; % 信号频率2
f3=200; % 信号频率3
f4=400; % 信号频率4
fs=800; % 采样频率
ts=1/fs; % 采样间隔
Ts=1:N; % 采样序列
x=0.3*cos(2*pi*f1*Ts*ts)+0.6*cos(2*pi*f2*Ts*ts)+0.1*cos(2*pi*f3*Ts*ts)+0.9*cos(2*pi*f4*Ts*ts); % 完整信号,由4个信号叠加而来
%% 2. 时域信号压缩传感
Phi=randn(M,N); % 测量矩阵(高斯分布白噪声)64*256的扁矩阵
s=Phi*x.';