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

New to MATLAB?

Problem 1278. Find the nearest integer

Created by Bruce Raine

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)



Problem Group

Solution Statistics

109 correct solutions 50 incorrect solutions
Last solution submitted on Oct 13, 2015

Problem Comments