Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

??? Subscripted assignment dimension mismatch. Error

조회 수: 1 (최근 30일)
Adam
Adam 2014년 5월 26일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi so Im getting this error when ever I try to run this section of code:
for i = 1:l
C2(i,1) = min ( G1(i,Xbp: Xep+3));
end
C2 is a 616x1 matrix G1 is a 616x498 matrix
Why is this occuring all of a sudden I have ran this code on similar programs and this is teh first time it occured.
Thanks.
  댓글 수: 1
Adam
Adam 2014년 5월 26일
편집: Matt J 2014년 5월 26일
Apologies this si more of the code:
G1 = 255 * mat2gray (I2 , [1 100]);
C2 = 0 * I2 (:,1)+1;
for i = 1:l
C2(i,1) = min ( G1(i,Xbp: Xep+3));
end
I2 is a 616x498 matrix
l = 616

답변 (1개)

dpb
dpb 2014년 5월 26일
Insufficient info to tell -- the problem would appear to be in what isn't shown.
Use debugger to stop on the error and examine the specific case values. Set
dbstop if error
then rerun.
The above code loop could be written as
C2=min(G1(:,G1(i,Xbp: Xep+3),2);
presuming that
I=size(G1,1);
If I<size(G1,1) then substitute the vector 1:I for I in the first subscript expression.
  댓글 수: 4
Adam
Adam 2014년 5월 26일
its an error carried through from actions taken in the code before this takes place. In this code it wants to go from Xbp to Xep (making Xbp the smaller value)but the error occurs because Xbp is larger than Xep.
So i need to go back and fix that from occuring.
dpb
dpb 2014년 5월 26일
...its an error carried through from actions taken in the code before this takes place...
Where did I hear that before??? VBG

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by