fix(23/5) % integer part rem(23,5) % remainder %or mod(23,5) Answer from Azzi Abdelmalek on mathworks.com
🌐
MathWorks
mathworks.com › matlab › mathematics › elementary math › arithmetic operations
idivide - Integer division with rounding option - MATLAB
This MATLAB function divides each element of A by the corresponding element of B, rounded to the nearest integers toward zero.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 857225-how-does-division-work-for-integer-types
How does division "/" = work for integer types? - MATLAB Answers - MATLAB Central
June 16, 2021 - Matlab is apparently the only programming language in the world today which does not do integer division in the standard way: "Integer division and remainder are defined by the relation A = (A/B)*B + (A rem B), where (A rem B) has the sign of ...
🌐
MATLAB Central
mathworks.com › matlabcentral › cody › problems › 60836-integer-division-without-remainder
Integer Division Without Remainder - MATLAB Cody - MATLAB Central
Write a function that takes two positive integers, a and b, and returns the result of integer division (quotient) without remainder. The function should return floor(a / b), meaning the largest integer that does not exceed the division result. ... Find the treasures in MATLAB Central and discover ...
🌐
MathWorks
mathworks.com › matlabcentral › answers › 860435-how-to-get-quotient-value-after-division-without-round-off
How to get quotient value after division without round off? - MATLAB Answers - MATLAB Central
June 19, 2021 - https://www.mathworks.com/matlabcentral/answers/860435-how-to-get-quotient-value-after-division-without-round-off#comment_1593240 ... Thankyou so much. Though same problem persisted in my code BUT i got another solution · as I subtracted remainder(from third line) from the number(n1) everytime so that it will give only interger value after division as shown:
🌐
MathWorks
mathworks.com › matlabcentral › answers › 1574108-how-can-i-programe-this-function-without-rem-or-mod
How can i programe this function without rem or mod? - MATLAB Answers - MATLAB Central
November 5, 2021 - the matlab programe ( function, one loop or two loops ) needs to solve for the quotient remainder theorem a = dq + r where the programe takes two integers as inputs the dividend a, and the diviso...
Find elsewhere
🌐
MathWorks
mathworks.com › symbolic math toolbox › mathematics › number theory
quorem - Quotient and remainder - MATLAB
Remainder of the division, returned as a symbolic integer, expression, or a vector or matrix of symbolic integers or expressions. ... Run the command by entering it in the MATLAB Command Window.
Top answer
1 of 3
39

Non-commutativity of multiplication

a/b calculates $a \cdot b^{-1}$, whereas b\a calculates $b^{-1} \cdot a$. Since matrix multiplication is not commutative, those are different operations.

2 of 3
10

Solving linear systems is better than inverting

The main reason is the one in xigoi's answer, noncommutativity, but let me add that a separate operator is handy to have for matrix operations: computing the matrix K = inverse(A) and then multiplying x = K * b is inferior from the point of view of both stability and computational cost. So considering A \ b as a single operation with two operands is more effective than thinking about it as "first invert $A$, then multiply by $b$".

Proxy object

An alternative design choice that solves the same problem and has some advantages is having a method K = factorize(A) which computes an LU factorization (or another more convenient factorization) of the matrix $A$, and returns an "inverse-like" object K for which a method K * b is defined. This choice is very convenient because it allows one to separate and reuse the most expensive part of linear system solution, which is the $O(n^3)$ factorization. So you can write the clearer and more efficient

K = factorize(A); % 2/3*n^3 + O(n^2) for a general nxn matrix A
x1 = K * b1;  % O(n^2) if b1 is a length-n vector
x2 = K * b2;  % O(n^2) if b2 is a length-n vector

rather than

x1 = A \ b1;  % 2/3*n^3 + O(n^2)
x2 = A \ b2;  % 2/3*n^3 + O(n^2)
% total cost 4/3*n^3: the factorization is computed twice.
% Also, with this syntax the factorization cannot be precomputed
% before knowing b1, b2

or

K = inv(A);  % 2*n^3 + O(n^2)
x1 = K * b1; % O(n^2)
x2 = K * b2; % O(n^2)
% x1, x2 computed in this way typically have a higher
% numerical error than A \ b, in floating point.

This "implicit inverse" trick is implemented in Matlab's decomposition, and (with more generality and more methods defined) in Julia's factorize.

In a new language. I can see arguments for going even further and calling this function inverse(A), making it the preferred syntax to perform matrix inversion and linear system solution.

🌐
MathWorks
mathworks.com › matlabcentral › answers › 31403-writing-a-function-for-division
Writing a function for division - MATLAB Answers - MATLAB Central
March 6, 2012 - Hi i am planning on writing a function based around division, and also include remainders. For example, 15/4= 3 remainder 3. My code so far is: function [q,r]=Divide(x,y) q=x/y q=floor(...
🌐
EDUCBA
educba.com › home › data science › data science tutorials › matlab tutorial › matlab remainder
Matlab Remainder | Complete Guide to Matlab Remainder | Examples
March 4, 2023 - Remainder: If the product Divisor * Quotient is not equal to the ‘Dividend’, then the lag is referred as ‘Remainder. In Matlab we use ‘rem’ function for the purpose of finding the remainder of a division.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
MathWorks
mathworks.com › matlabcentral › answers › 403870-difference-between-mod-and-rem-functions
Difference between mod and rem functions - MATLAB Answers - MATLAB Central
May 11, 2011 - The outputs of rem and mod are the same if the inputs have the same sign, otherwise it depends on how the division is interpreted. The MATLAB documentation states that "The concept of remainder after division is not uniquely defined, and the two functions mod and rem each compute a different ...
🌐
Stack Overflow
stackoverflow.com › questions › 22643820 › how-rem-function-works-in-matlab
division - How rem function works in matlab - Stack Overflow
The function rem() calculates the remainder after division. In the equation a = qd + r, the number q is the quotient and r is the remainder. The quotient q is a natural number, i.e. 0,1,2,3, etc, while the remainder r is in the range 0<=r<d. ...
🌐
MathWorks
mathworks.com › matlabcentral › answers › 109143-polynomial-division-issue-how-to-find-the-remainder
polynomial division issue, how to find the remainder - MATLAB Answers - MATLAB Central
December 8, 2013 - This is a quote from that documentation: "If u and v are vectors of polynomial coefficients, convolving them is equivalent to multiplying the two polynomials, and deconvolution is polynomial division. The result of dividing v by u is quotient q and remainder r." ... https://www.mathworks.com/matlabcentral/answers/109143-polynomial-division-issue-how-to-find-the-remainder#comment_184418