Indexing cannot yield multiple results

조회 수: 4 (최근 30일)
Stelios Fanourakis
Stelios Fanourakis 2017년 12월 11일
답변: Steven Lord 2017년 12월 11일
What is the wrong in this code?
WL2R=0;
if (nargin < 2)
[Rmin Rmax] = WL2R(Win, LevV);
elseif numel(disprange) == 0
[Rmin Rmax] = WL2R(Win, LevV);
else
LevV = (double(disprange(2)) + double(disprange(1))) / 2;
Win = double(disprange(2)) - double(disprange(1));
WLAdjCoe = (Win + 1)/1024;
[Rmin Rmax] = WL2R(Win, LevV);
end
  댓글 수: 2
Jos (10584)
Jos (10584) 2017년 12월 11일
How are we supposed to know ... :) Since you get the error message or incorrect result, show that to us!
Stelios Fanourakis
Stelios Fanourakis 2017년 12월 11일
The first line [Rmin Rmax] = WL2R(Win, LevV); Gets the error (see topic)

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

답변 (1개)

Steven Lord
Steven Lord 2017년 12월 11일
WL2R=0;
if (nargin < 2)
[Rmin Rmax] = WL2R(Win, LevV);
The third line of that code segment may be an attempt to call a function WL2R. But because of the first line of that segment, it is instead interpreted as an attempt to index into the variable WL2R, and as the error message correctly states indexing cannot yield multiple results.
If you intended to call that function, don't define a variable with the same name. If you intended to index the variable, specify only one expression on the left side of the equals sign.

Community Treasure Hunt

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

Start Hunting!

Translated by