Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get quotient in integer division in matlab?

Tags:

matlab

I wonder how to get quotient in integer division in MATLAB? Thanks and regards!

like image 775
Tim Avatar asked Dec 28 '22 20:12

Tim


2 Answers

Use idivide:

C = idivide(A, B) is the same as A./B except that fractional quotients are rounded toward zero to the nearest integers.

There's a third optional parameter for controlling the rounding behavior that's explained on the MathWorks site that I linked to.

like image 77
Bill the Lizard Avatar answered Jan 08 '23 17:01

Bill the Lizard


Simply, put as following:

floor(A/B)

floor command rounds the value to the nearest integer, towards negative infinity (-inf).

like image 44
Wings Avatar answered Jan 08 '23 15:01

Wings