Help me about my error on index in position 2 exceeds array bounds (must not exceed 800).

조회 수: 1 (최근 30일)
after=before; %Inisialisasi matriks hasil untuk memuat tanda air
for i=1:rm %Sematkan watermark di mid-band
for j=1:cm
x=(i-1)*8;
y=(j-1)*8;
if mark(i,j)==1
k=k1;
else
k=k2;
end;
after(x+1,y+8)=before(x+1,y+8)+alpha*k(1);
after(x+2,y+7)=before(x+2,y+7)+alpha*k(2);
after(x+3,y+6)=before(x+3,y+6)+alpha*k(3);
after(x+4,y+5)=before(x+4,y+5)+alpha*k(4);
after(x+5,y+4)=before(x+5,y+4)+alpha*k(5);
after(x+6,y+3)=before(x+6,y+3)+alpha*k(6);
after(x+7,y+2)=before(x+7,y+2)+alpha*k(7);
after(x+8,y+1)=before(x+8,y+1)+alpha*k(8);
end;
end;
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 12월 22일
My guess is that (cm-1)*8+8 == 8*cm exceeds the number of columns in before .
But that is only a guess, as we do not know the size(before) or what the values of rm or cm are.
TADA
TADA 2019년 12월 22일
look here
always copy the entire error message, and tell us from which line of code it originated
moreover, in general, sample data would go a long way

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

답변 (1개)

TADA
TADA 2019년 12월 22일
I have no idea what rm and cm are, but at some iteration
y=(j-1)*8 + 8
is greater than the number of columns in your matrix
under the editor menu, you have the run button, if you expand the run menu you can check the "pause on errors"
to easily debug this error

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by