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

52.71% Correct | 47.29% Incorrect
Last Solution submitted on Mar 10, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers334

Suggested Problems

More from this Author16

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!