MATLAB command locateVal

In two previous posts I shared some MATLAB code to help design collection optics in 2p scopes.
Collection optics for 2p scopes, post 1
Collection optics for 2p scopes, post 2
It was just brought to my attention that I didn’t include the command locateVal in the code I posted. It’s a very simple little shortcut I use. Here it is:

function [pos difference] = locateVal(val,data)
[difference pos] = min(abs(data - val));


Yes, you could have guessed that. But I wanted to correct the oversight.