⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 perf_test_online.asv

📁 code for homotopy in compressed sensing
💻 ASV
字号:
clear;

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

m = 2000;
CS_iter_Time = 2;
GS_iter_Time = 1;
block = 0;
SNR = 10000;
countNoise = 1;
testTime = 200;
testK = [10, 40, 100];

for kIdx = 1:3
        slotNum = [];
        miniResidual = [];    
        k = testK(kIdx);
        miniResidual = 0;
        avgSlotNum = 0;
        for testIdx = 1 : testTime     
           % generate the matrix and signal
           signal = zeros(m,1);
           signal(1:k) = 1;
           meas = randn(m,m);
           Y = meas * signal + rand(m,1)/sqrt(SNR);        
                
           % initialization
           A(1:60,:)*Y(1:60)
           
           % solve it increamentally                      
           for sampNum = 60:20:m
               currErr = norm(Y(1:sampNum)-meas(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, oldx, newA, newy, lambda, J, cJ);
               
               % determine whether reset the initial value
               currErr = norm(Y(1:sampNum)-meas(1:sampNum,:)*x);
           end
           
           miniResidual = [miniResidual, norm(x-signal)];           
           slotNum = [slotNum, sampNum];
           [kIdx, testIdx, norm(x-signal), sampNum]                               
        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);        

⌨️ 快捷键说明

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