Difference between revisions of "Matlab:Division operators"
(New page: ==Division operators in Matlab=== There are (at least) four different division functions in Matlab: '''./''', '''.\''', '''/''', and '''\'''. These four symbols are shorthand for the Matla...) |
|||
Line 1: | Line 1: | ||
+ | [[Category:Matlab]] | ||
==Division operators in Matlab=== | ==Division operators in Matlab=== | ||
There are (at least) four different division functions in Matlab: '''./''', '''.\''', '''/''', and '''\'''. These four symbols are shorthand for the Matlab functions: [http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/rdivide.html rdivide], | There are (at least) four different division functions in Matlab: '''./''', '''.\''', '''/''', and '''\'''. These four symbols are shorthand for the Matlab functions: [http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/rdivide.html rdivide], |
Latest revision as of 14:15, 10 September 2009
Division operators in Matlab=
There are (at least) four different division functions in Matlab: ./, .\, /, and \. These four symbols are shorthand for the Matlab functions: rdivide, ldivide, mrdivide, and mldivide, respectively.
Element-by-element right divide
A ./ B divides each element of matrix A by the corresponding value in matrix B. A and B must be the same size. If either A or B is a scalar, Matlab will expand the argument to be the size of the other argument. The result is a matrix of the same size as A and B. Examples:
Matrix right divide
A / B
Template:Note|Use the element-by-element divide operator (./) instead of the matrix divide operator(/) so that the temperature parameter T can be a vector. If T is a single value, both operators are equivalent. But the / operator will try to do a matrix divide if T is a vector or matrix and give an error since the dimension of the two operands do not match. A for...end loop could also be used to call DnaFraction once for each value of $ T $. But for loops have terrible performance in Matlab and your program will run much faster if you use a vector of $ T $ values instead.}}