what does c(:).' mean? c should be a vector
72 views (last 30 days)
Yuji Zhang on 24 Aug 2014
Hi I saw this in Matlab document:
function obj = DocPolynom(c)
% Construct a DocPolynom object using the coefficients supplied
obj.coef = c.coef;
obj.coef = c(:).';
What does c(:).' mean? Is .' the transpose of each element? But I think c should be a vector here. Any help's appreciated. Thanks!
Source of the above code: http://www.mathworks.com/help/matlab/matlab_oop/a-polynomial-class-1.html
Matz Johansson Bergström on 24 Aug 2014
By writing c(:)' you are making sure that the vector has the dimension 1xn, where n is the length of the vector, a row vector. However, there is a very important difference between c(:).' and c(:)', because they are not the same.
The difference is when you are working with complex vectors, for instance
tmp = (1:5) + 1i;
which gives you each complex number in a row vector, compared to
which is giving you a row vector of the complex conjugate of each element.
More Answers (1)
Roger Stafford on 24 Aug 2014
This is a short way to reshape c, whether it is a vector or array, into a row vector. You are then guaranteed that obj.coef will be a vector with just one row and however many columns as there are elements in c.
will do the same thing.