Problem 1278. Find the nearest integer

Created by Bruce Raine in Community

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

59.45% Correct | 40.55% Incorrect
Last solution submitted on Feb 10, 2019

Problem Comments

Recent Solvers171

Suggested Problems

More from this Author16

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!