Rahul Gupta
Rahul Gupta

Reputation: 1802

Roundoff Decimal to it nearest integer in Matlab

I have an array of 20 elements and I am trying to round off all the elements in the array to its nearest integer.
For example, 1.3 should be rounded off to 1 and 1.6 should be rounded off to 2.
Thanks in Advance

Upvotes: 0

Views: 58

Answers (1)

Sardar Usama
Sardar Usama

Reputation: 19689

array = 20*rand(20,1)  %random values for an array of 20 elements
round(array)

Upvotes: 1

Related Questions