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

1 vue (au cours des 30 derniers jours)
Jajang Khairil Azhar le 22 Déc 2019
Réponse apportée : TADA le 22 Déc 2019
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 commentairesAfficher AucuneMasquer Aucune
Walter Roberson le 22 Déc 2019
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.
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

Connectez-vous pour commenter.

### Réponses (1)

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 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by