




0001 function out = OMP_function(y,A,in) 0002 0003 [M N] = size(A); 0004 Te = M; 0005 if isfield(in,'Te') 0006 Te = in.Te; 0007 end 0008 thresh = 1e-5; 0009 if isfield(in,'thresh') 0010 thresh = in.thresh; 0011 end 0012 0013 [val_max gamma_omp] = max(abs(A'*y)); 0014 0015 for iter = 1:Te 0016 x_omp = zeros(N,1); 0017 x_omp(gamma_omp) = A(:,gamma_omp)\y; 0018 r_omp = y-A*x_omp; 0019 if norm(r_omp)< thresh 0020 break; 0021 end 0022 p_omp = A'*r_omp; 0023 gamma_ompC = setdiff([1:N],gamma_omp); 0024 [val_omp, ind_omp] = max(abs(p_omp(gamma_ompC))); 0025 gamma_omp = [gamma_omp; gamma_ompC(ind_omp)]; 0026 end 0027 out = []; 0028 out.x_out = x_omp; 0029 out.gamma = gamma_omp; 0030 out.iter = iter;