On the assumption it really is to remove the full row/column, not the individual element, "Dead ahead" is sometimes the simplest...
NB: Your example above will fail as B(end)>size(A,2)
If the intent is to remove the row even if there isn't such a column, then incorporate error testing or just use a try...catch block to skip the addressing error.
try, A(B(i),:)=; catch,end
try, A(:,B(i))=; catch,end