Given a vector or matrix X, CLOSEST(X,b) finds the element in X that is nearest to the scalar b.
>> X = [-1 -2 6.14 9];
>> b = pi;
>> c = closest(X,b)
Matt (2023). Closest (https://www.mathworks.com/matlabcentral/fileexchange/42121-closest), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!