Trying to understand MATLAB syntax: I see that
(0:3)
is a row vector, that the '
(forward-quote) operator is transpose
, so
(0:3)'
is a column vector. I have also seen .'
in some files, and these also produce column vectors, so
(0:3).'
produces the same result as (0:3)
.
What is the difference between '
and .'
? I haven't found anything in the MATLAB docs to help me understand this.
(note that this question is about syntax, primarily, not about the difference between transpose
and ctranspose
, because if you don't know that '
is one and .'
is the other, than an answer to the question of transpose
versus ctranspose
is of no help answering the question of .
versus '.
. In many MATLAB examples and tutorials, '
is glibly and inaccurately presented as transpose
, and that fact leads to the question when a user first encounters .'
.)
dot(A,B,1) treats the columns of A and B as vectors and returns the dot products of corresponding columns. dot(A,B,2) treats the rows of A and B as vectors and returns the dot products of corresponding rows.
Accepted AnswerThe dot indicates element-wise as opposed to array operations. See the documentation on Array vs. Matrix Operations for details.
There is no difference for real numbers.
For complex numbers .'
will produce transpose, while '
will produce the complex conjugate.
>> [i -i].'
ans =
0.0000 + 1.0000i
0.0000 - 1.0000i
>> [i -i]'
ans =
0.0000 - 1.0000i
0.0000 + 1.0000i
By the way, each Matlab operator has a name, which can be used to read the documentation.
.'
- transpose
'
- ctranspose
Though it is hard to find them in the documentation sometimes. Most of them can be found in here, but you will have to guess which operator is which.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With