gendatafig04cd_random.m
来自「一种基于压缩感知技术的图像重建程序」· M 代码 · 共 62 行
M
62 行
%-------------------------------------------------------------------
% This code generates Figure 4cd (Random) of the following paper:
% "Bayesian Compressive Sensing" (Preprint, 2007).
% The dataset used is similar to the one used in l1qc_example.m,
% an example from l1magic.
% Coded by: Shihao Ji, ECE, Duke University
% last change: Jan. 2, 2007
%-------------------------------------------------------------------
clear all
%
total_count = 100;
N = 512; % signal length
T = 20; % number of spikes
dN = 1;
base = 40; % number of initial random measurements
ns = 80; % number of additional random measurements
sigma = 0.005;
%
for count = 1:total_count
count
rand('state', count);
randn('state', 2*count);
%
% random +/- 1 signal
x = zeros(N,1);
q = randperm(N);
amp = randn(T,1);
x(q(1:T)) = amp*sqrt(T/sum(amp.^2)); %re-scaled to have the same SNR as in Fig.2
% noisy observations
A = randn(base,N);
A = 1.01*A./repmat(sqrt(sum(A.^2,2)),[1,N]);
e = sigma*randn(base,1);
y = A*x + e;
for i = 1:ns
K = base+i*dN;
a = randn(dN,N);
a = 1.01*a/sqrt(sum(a.^2));
% noisy observations
e = sigma*randn(dN,1);
t = a*x + e;
y = [y;t];
A = [A;a];
initsigma2 = std(y)^2/1e2;
[weights,used] = BCS_fast_rvm(A,y,initsigma2,1e-8);
%
xp = zeros(N,1);
xp(used) = weights;
err(count,i) = norm(x-xp)/norm(x);
end
end
%
save DataFig04cd_random.mat err;
beep;
disp('Done!');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?