5 lines
197 B
Mathematica
5 lines
197 B
Mathematica
|
function idx = findNearestValue(array, value)
|
||
|
array = double(array);
|
||
|
[~, idx] = min(abs(array - value)); % Find the index of the element with the minimum absolute difference from value
|
||
|
end
|