function index = nma_get_index(x,h) %helper function to find index xq = floor(x/h)*h; if x-xq > h/2 xq = xq+h; end index = round(xq/h)+1; end