I'm trying to extract from a 2-D matrix with id values the neighboring ids of each element on the board.
I have a list of of IDs and their coordinates (of n elements), and I'm creating the following: (Example for left neighbor only).
%Left:
leftIndex = (currentLocationIndex - bSize);
hasLeft = leftIndex >= 1; %If element on first col, value will be 0 or negative
hasLeft = hasLeft(:) & board(leftIndex)==0;
I get: Subscript indices must either be real positive integers or logicals.
I want to use the pricipal of && operand or some other logic. the leftIndex contains all the indices left to a current index in the table. Some are legal some arn't. If hasLeft vector is true then the leftIndex vector value is legal in the 'board'.
How can I check for a neighbor in a certain value of the vector only if the hasLeft is true?
Thanks!