MATLAB: How to check divisibility divisionvariables Hi, I need to check whether two numbers are divisible or not. But how can I do that in Matlab? e.g. Matlab gives 1.5 for 3/2 but I need to get 3/2 = 0 and 4/2 =2. Best Answer a=3;b=2;out=~rem(a,b)*a/b Related SolutionsMATLAB: How to find next number divisible by n b = a + (n - rem(a,n))Best wishesTorsten. MATLAB: In documentation it says mod(a,m) will give the remainder of a/m with example mod(23,5) = 3. However 23/5 is 4.6, 4 with a remainder 6 not 3. Whats going on here You are misinterpreting the mod function. Illustrating — num = 23den = 5quotient = fix(num/den)modulus = num - quotient*denproducing: quotient = 4modulus = 3Also: modulus = (num/den - quotient) * denwith the same result. Related QuestionAdd zero to make length divisible by 3Divide every entry of a column by the same numberHow do you write function divisible(n)Dividing vectors to get a matrix, as if it were multiplicationHow to get a number A which is divisible by a specific number B
Best Answer