Skip to content

Instantly share code, notes, and snippets.

@mattgaidica
Created November 26, 2018 01:22
Show Gist options
  • Save mattgaidica/6da9f91fe5d673152d49133ce97ee9ff to your computer and use it in GitHub Desktop.
Save mattgaidica/6da9f91fe5d673152d49133ce97ee9ff to your computer and use it in GitHub Desktop.
function [idx, val] = closest(testArr,val)
tmp = abs(testArr - val);
[~, idx] = min(tmp);
val = testArr(idx);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment