How to solve "Indexing cannot yield multiple results."

3 views (last 30 days)
I'm trying to construct a basic OFDM simulation, and run into some problems when I trying to demodulate the signal to digit number.
the error is in last line 4 with min function.
%remove CP
Rsig=Rxsig(1,Ncp+1:end);
sig=fft(Rsig,N); %singal=<1x128>,128 is the subcarrier number
%demodulation
for jj=1:N
sig4=[sig(1,jj) sig(1,jj) sig(1,jj) sig(1,jj)];
[min, pos]=min(floor((abs(sig4-temp)*1000)'));
% find the nearest signal
% temp=(1/sqrt(2))*[1+1j 1-1j -1+1j -1-1j];
end
or is there a better way to demodulate the signal ? Thank you for answering !!!

Accepted Answer

Walter Roberson
Walter Roberson on 13 Aug 2015
Edited: Stephen23 on 13 Aug 2015
In your loop, you call the MATLAB min() function, and you assign the output to [min, pos]. This makes min a numeric variable where it used to be a call to the MATLAB function. Then in the second iteration of the "for" you are indexing the numeric variable because that's what min is now, and you are expecting to be able to get two outputs, [min, pos]. But indexing of something using () only gives you a single output never two outputs, so MATLAB complains.
To fix this... don't name your variables the same thing as MATLAB routines!
  2 Comments
Stephen23
Stephen23 on 13 Aug 2015
Edited: Stephen23 on 13 Aug 2015
In case that is not clear enough: do NOT use any inbuilt names such as min, max, path, i, j, length, size, struct, date, time, etc, etc for variable or function names. You can check what names are already assigned using the which function.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!