MATLAB: How to solve “Indexing cannot yield multiple results.”

indexingmultiple results

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 !!!

Best Answer

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!