function a = nrst(v,x) % a = nrst(v,x) % find element of v nearest x % Ivan Selesnick v = v(:); [tmp,k] = min(abs(v - x)); a = v(k);