function [ j ] = state_j( state ,m) j = state - m*(floor((state-1) / m)); end