Problem 1278. Find the nearest integer

Given a vector of integers and a real number find the closest integer.


>> a = [2 4 5 6 8 10];

>> b = 4.6;

>> nearestNumber(a,b)


Solution Stats

63.75% Correct | 36.25% Incorrect
Last solution submitted on Oct 13, 2017

Problem Comments


Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!