perf_test_online.m

来自「code for homotopy in compressed sensing」· M 代码 · 共 51 行

M
51
字号
clear;

rand('seed', 1);
randn('seed', 1);

k = 50;
m = 500;
testTime = 200;

for kIdx = 1:3
    for testIdx = 1 : testTime     
        % generate the matrix and signal
        signal = zeros(m,1);
        signal(1:k) = 1;
        A = randn(m,m);
        Y = A * signal;        
        
        % initialization
        c = A(1:40,:)'*Y(1:40);
        [lambda,J] = max(abs(c));
        cJ = exclude(m,J);           
        x  = zeros(m,1);        
                           
        % solve it increamentally                      
        for sampNum = 60:20:m
            currErr = norm(Y(1:sampNum)-A(1:sampNum,:)*x);
            if currErr / norm(Y(1:sampNum)) < 1e-2
               break;
            end
               
            % solve using the current observations
            oldA = A(1:sampNum-20,:);
            oldy = Y(1:sampNum-20);
            newA = A(sampNum-19:sampNum,:);
            newy = Y(sampNum-19:sampNum);
            [x, J, cJ, lambda] = onlineHomotopy(oldA, oldy, x, newA, newy, lambda, J, cJ);
               
        end
           
        % record results
        filename = sprintf('ol_GSresult_%d_%d_%.3f_%d.txt', GS_iter_Time,CS_iter_Time,SNR, countNoise);        
        fp = fopen(filename,'a');
        fprintf(fp,'%d %d %d ', GS_iter_Time,CS_iter_Time, k);
        fprintf(fp,'%f ', miniResidual / testTime);
        for t = 1 : length(slotNum)
            fprintf(fp,'%d ', slotNum(t));
        end
        fprintf(fp,'\n');
        fclose(fp);        
    end
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?