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
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
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
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!