function error while using sb2ind function

there is an errror in sub2ind function when i type the following: indTerm=sub2ind([m,n],CentroidTerm(:,1),CentroidTerm(:,2));
it says that "out of range subscript"
plz tell me what is the problem. }

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2011년 7월 19일

0 개 추천

conditions to work correctly
isequal(~rem(CentroidTerm,1),bsxfun(@ge,CentroidTerm ,[1 1]),bsxfun(@le,CentroidTerm ,[m n]))

추가 답변 (2개)

Walter Roberson
Walter Roberson 2011년 7월 19일

0 개 추천

Is any member of CentroidTerm(:,1) less than 1 or greater than m? Is any member of CentroidTerm(:,2) less than 1 or greater than n? Is it possible that you have accidentally created a variable named "sub2ind" ?
Friedrich
Friedrich 2011년 7월 19일

0 개 추천

Hi,
it seems like a value in CentroidTerm(:,1) is bigger than m or a value in CentroidTerm(:,2) is bigger than n.

카테고리

도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by