What do you expect line 9, which is A(i,j)-A(i+1,j)==-1;, to do? Do you want to run lines 10-15 only if that condition is satisfied? If so, what you should do depends on whether A(i, j)-A(i+1, j) can only take on the values 1 or -1 or if it can take on other values (like 0) as well.
If that difference can ONLY be 1 or -1, you don't need the check. If you reach the else you know the difference was not 1, so by process of elimination it must be -1.
If the difference can be something other than 1 or -1, you probably want to use an elseif statement. The first example on the documentation page for the if keyword shows how to use elseif to check for a series of conditions in turn.