why do I get the error : Index exceeds matrix dimensions?

조회 수: 2 (최근 30일)
bena
bena 2014년 8월 27일
댓글: bena 2014년 8월 29일
hello all! I am trying to do channel estimation using compressive sensing using basis pursuit denoising from spgl in matlab. following is my code segment. but I am constantly getting the error:
Index exceeds matrix dimensions.
Error in partialFourier (line 8)
y = z(idx);
Error in @(x,mode)partialFourier(p,ofdm.N,x,1)
Error in aunt (line 106)
Rb=opA(y(i),1);
I have tried to match the dimensions of both but its not working. can anyone help me please.
%%%%%%%%%%%%%%%%%%code for spg_bpdn%%%%%%%%%%%%%%
ofdm.N=128;
ofdm.PP=13;
ofdm.B=1;
%%Saprse Channel estimation
H_Sparse = zeros(ofdm.N,ofdm.B);
m=50;k=14;
for b = 1 : ofdm.B
p = randperm(ofdm.N); p = p(1:k);
opts = spgSetParms('verbosity',0);
opA= @(x,mode) partialFourier(p,ofdm.N,x,1);
y=zeros(ofdm.N,1);
y(p) = ofdm.N/ofdm.NP *fft(ifft(dataRxFFT(ofdm.PP,1)));
y=y(p);
Rb=opA(y(p),1);
x=spg_bpdn(@(x,mode)opA(x,mode),Rb,0.05,opts);
H_Sparse(:,1)=ofdm.N/ofdm.NP * fft(ifft(vec2mat(x,ofdm.N)));
end
  댓글 수: 3
Image Analyst
Image Analyst 2014년 8월 27일
fft(ifft(X)) = X, so what's going on there?
bena
bena 2014년 8월 28일
편집: dpb 2014년 8월 28일
I think the issue is with dataRxFFT, I tried to do
fft(ifft(dataRxFFT(ofdm.PP,1)))
but the problem is still there. idx and y have same dimensions when I use the following lines of code:
y(p) = ofdm.N/ofdm.NP *fft(ifft(dataRxFFT(ofdm.PP,1)));
y=y(p);
Rb=opA(y(p),1);
yet, the error remains the same. when I run the same code without dataRxFFT, i.e. by using
y(p)=randn(k,1) + sqrt(-1) * randn(k,1);
the code compiles and correct results are generated. but when I use dataRxFFT I get the error. any ideas??

댓글을 달려면 로그인하십시오.

채택된 답변

dpb
dpb 2014년 8월 28일
편집: dpb 2014년 8월 28일
It took a while to puzzle thru what you're doing...I still have absolutely no klew as to why one would do this, but...
The problem in dimension arises by the way you're generating the vector y as
y(p)=...
y=y(p);
then subsequently you then try to refer to y w/ the subscript vector p again.
The assignment of
y=y(p);
turns size(y) into [length(p),1] or, in the example given length(y) is now 14. But, the p index vector is a permutation of a subset of 14 values between 1-128 by
p = randperm(ofdm.N); p = p(1:k);
So, excepting for the one case which will likely never occur, you're trying to reference some non-existent value >14 in y with the subsequent assignment via the index vector p
Don't know what you want for a final output, but that's the problem with your indexing expression as written. OTHO,
Rb=opA(y,1);
will work if you want an input vector of the 14 values only w/o the zero-fill in the original.

추가 답변 (1개)

bena
bena 2014년 8월 29일
this is the working code segment. thankx all!!
%% Saprse Channel estimation H_Sparse = zeros(ofdm.N,ofdm.B); m=50;
for b = 1 : ofdm.B
idx=randperm(ofdm.N);idx=idx(1:m);
p = randperm(ofdm.N); p = p(1:k);%p=p';
opts = spgSetParms('verbosity',0);
%u_fft=zeros(ofdm.N,1);
opA= @(x,mode) partialFourier(idx,ofdm.N,x,mode);
y=zeros(ofdm.N,1);
y(p) =dataRxFFT(ofdm.PP,b);
Rb=opA(y,1);
x=spg_bpdn(@(x,mode)opA(x,mode),Rb,0.05,opts);
H_Sparse(:,1)=ofdm.N/ofdm.NP * fft(ifft(vec2mat(x,ofdm.N)));
end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by