errflag = 0
% your loop. If warning criteria are met, set errflag to 1 and store the index.
if errflag
warning('Something went wrong for j = %s',sprintf('%u ',IndicesOfJ));
end
For example:
IndicesOfJ = [1 3 4 5];
warning('Something went wrong for j = %s',sprintf('%u ',IndicesOfJ));
Returns
Warning: Something went wrong for j = 1 3 4 5