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

Problem 1278. Find the nearest integer

Created by Bruce Raine

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

Tags

Problem Group

Solution Statistics

90 correct solutions 40 incorrect solutions
Last solution submitted on Oct 03, 2014

Problem Comments