基于GA和MP的信号稀疏分解matlab程序
基于GA和MP的信号稀疏分解
%% MATLAB script for MP algorithm based on FFT
%
%
%******************** Preparation part *****************************
%
%************************** part 1:imput signal ***************************
Im=wavread('FEM');
Im=Im';
%**************************** part 2: set parameters ***********************
f1=50;
f2=160;
fs=200;
iterative_number=100; % the matching pursuit processing iterative number
[a,N]=size(Im); % the longth of signal and the longth of atoms; N
a_base=2; % scale: the scale is determined by a and j;
j_min=0;
j_max=log2(N);
u_base=1/2; % the transmission or displacement u should determined as following
v_base=pi; % the frequency v
k_min=0;
w_base=pi/6; % the phase w
i_min=0;
i_max=12;
%%************************ initialization ********************************
signal=Im;
signal_reconstruct=zeros(1,N);
signal_r=Im;
%*************** wipe off the direct current vector *************************
signal_reconstruct=(1/N)*sum(signal);
signal_r=signal-signal_reconstruct;
%*********************start calculation*********************************
for n=1:iterative_number
% ********the following program uses one subroutine to select the best atom**************
[proj,scale,translation,freq,phase]=gas(signal_r,N,a_base,j_min,j_max,u_base,p_min,v_base,k_min,w_base,i_min,i_max);
%******reconstruct the best atom from the parameters got by above subroutine*********
t=0:N-1;
t=(t-translation)/scale;
g=(1/sqrt(scale))*exp(-pi*t.*t).*cos(freq*t+phase);
g=g./sqrt(sum(g.*g)); %normalizatiom the atom
%***********reconstruct signal and renew the residual**********************
signal_reconstruct=signal_reconstruct+proj*g;
signal_r=signal_r-proj*g;
%************************* the figure of result ************************
subplot(221);
plot(signal); % original siganl
subplot(222);
plot(g); %the atom
subplot(223);
plot(signal_r); %the residual
subplot(224);
plot(signal_reconstruct); %reconstruct s