Asked by karim
on 29 Apr 2013

i want a programme to approximate decimal to number

EX:

if I have 2.1 or 2.3 or 2.3 or 2.4

I want the answer to be 2

and if i have 2.5 till to 2.9

I want the answer to be 3

but the number is variable

I mean (2) can be 1,2,3,4,.....and so on

any number i can enter it

*No products are associated with this question.*

Answer by the cyclist
on 29 Apr 2013

Edited by the cyclist
on 29 Apr 2013

Accepted answer

Do you just need the round() function?

>> round(2.3)

ans =

2

Show 7 older comments

Jan Simon
on 29 Apr 2013

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

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments