运行OMP算法时,matlab中出现“Undefined function or variable 'x'.”。
%CoSaMP:ACHA(2009)301-321%2010-12-06%sy1133@163.com%clear;clc%m=128;%测量次数%d=256;%信号长度...
% CoSaMP: ACHA (2009) 301-321
% 2010-12-06
% sy1133@163.com
% clear;clc
% m = 128; % 测量次数
% d = 256; % 信号长度
% s = 40; % 稀疏度
% Phi = randn(m,d); % 测量矩阵
% %Generate sparse signal
% z = randperm(d);
% x = zeros(d, 1);
% x(z(1:s)) = sign(randn(s,1));
% %Generate measurements
% u = Phi*x;
%Begin CoSaMP
%Initialize
function Rec=CoSaMP(u,Phi,s)
d=size(Phi,2);
a = zeros(d,1);
v = u;
it=0;
stop = 0;
while ~stop
%Signal Proxy
y = Phi'*v;
[tmp, ix] = sort(abs(y), 'descend');
Omega = ix(1:2*s);
[tmp, ix] = sort(abs(a), 'descend');
T = union(Omega, ix(1:s));
%Signal Estimation
b = zeros(d, 1);
b(T) = Phi(:, T) \ u;
%Prune
[tmp, ix] = sort(abs(b), 'descend');
a = zeros(d, 1);
a(ix(1:s), 1) = b(ix(1:s), 1);
%Sample Update
v = u - Phi*a;
%Iteration counter
it = it + 1;
%Check Halting Condition
if norm(a-x) <= 10^(-4) || it > max(8*s)
stop = 1;
end
end %End CoSaMP iteration
disp(it);
stem(x,'LineStyle','none') %重构后的信号,蓝色圆圈
hold on
stem(a,'r','.','LineStyle','none') %原始信号,红点
其实我有定义这些数据,
clear;clc
m = 128; % 测量次数
d = 256; % 信号长度
s = 40; % 稀疏度
Phi = randn(m,d); % 测量矩阵
% %Generate sparse signal
z = randperm(d);
x = zeros(d, 1);
x(z(1:s)) = sign(randn(s,1));
% %Generate measurements
u = Phi*x; 展开
% 2010-12-06
% sy1133@163.com
% clear;clc
% m = 128; % 测量次数
% d = 256; % 信号长度
% s = 40; % 稀疏度
% Phi = randn(m,d); % 测量矩阵
% %Generate sparse signal
% z = randperm(d);
% x = zeros(d, 1);
% x(z(1:s)) = sign(randn(s,1));
% %Generate measurements
% u = Phi*x;
%Begin CoSaMP
%Initialize
function Rec=CoSaMP(u,Phi,s)
d=size(Phi,2);
a = zeros(d,1);
v = u;
it=0;
stop = 0;
while ~stop
%Signal Proxy
y = Phi'*v;
[tmp, ix] = sort(abs(y), 'descend');
Omega = ix(1:2*s);
[tmp, ix] = sort(abs(a), 'descend');
T = union(Omega, ix(1:s));
%Signal Estimation
b = zeros(d, 1);
b(T) = Phi(:, T) \ u;
%Prune
[tmp, ix] = sort(abs(b), 'descend');
a = zeros(d, 1);
a(ix(1:s), 1) = b(ix(1:s), 1);
%Sample Update
v = u - Phi*a;
%Iteration counter
it = it + 1;
%Check Halting Condition
if norm(a-x) <= 10^(-4) || it > max(8*s)
stop = 1;
end
end %End CoSaMP iteration
disp(it);
stem(x,'LineStyle','none') %重构后的信号,蓝色圆圈
hold on
stem(a,'r','.','LineStyle','none') %原始信号,红点
其实我有定义这些数据,
clear;clc
m = 128; % 测量次数
d = 256; % 信号长度
s = 40; % 稀疏度
Phi = randn(m,d); % 测量矩阵
% %Generate sparse signal
z = randperm(d);
x = zeros(d, 1);
x(z(1:s)) = sign(randn(s,1));
% %Generate measurements
u = Phi*x; 展开
2个回答
展开全部
你的调用函数里的x没有定义
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询