Problem 1278. Find the nearest integer
Given a vector of integers and a real number find the closest integer.
EX:
>> a = [2 4 5 6 8 10];
>> b = 4.6;
>> nearestNumber(a,b)
ans=5
Solution Stats
Problem Comments
-
1 Comment
andrea84
on 22 Feb 2013
I think you have to improve the test suite
Solution Comments
Show commentsProblem Recent Solvers342
Suggested Problems
-
Remove any row in which a NaN appears
8549 Solvers
-
1704 Solvers
-
How to find the position of an element in a vector without using the find function
2706 Solvers
-
Given a matrix, swap the 2nd & 3rd columns
1039 Solvers
-
Calculate Amount of Cake Frosting
23663 Solvers
More from this Author16
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!