what does c(:).' mean? c should be a vector
Mostra commenti meno recenti
Hi I saw this in Matlab document:
function obj = DocPolynom(c)
% Construct a DocPolynom object using the coefficients supplied
if isa(c,'DocPolynom')
obj.coef = c.coef;
else
obj.coef = c(:).';
end
end
What does c(:).' mean? Is .' the transpose of each element? But I think c should be a vector here. Any help's appreciated. Thanks!
Risposta accettata
Più risposte (1)
Roger Stafford
il 24 Ago 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.
reshape(c,[],1)
will do the same thing.
4 Commenti
Yuji Zhang
il 24 Ago 2014
Image Analyst
il 24 Ago 2014
Correct, no matter what c is to start with c(:) turns it into a column vector. Then ' transposes it into a row vector. The dot means "element by element" which doesn't really have any meaning here (since c is a 1D vector and it's not operating on any other variable) so c(:).' is the same as c(:)'.
Roger Stafford
il 24 Ago 2014
No, the dot prevents matlab from taking the complex conjugate of elements along with the transposition. It has nothing to do with element-by-element operation. Their documentation says: "b = a.' computes the non-conjugate transpose of matrix a and returns the result in b" and "b = a' computes the complex conjugate transpose of matrix a and returns the result in b."
If c is entirely real-valued, then c(:).' and c(:)' are the same.
Yuji Zhang
il 25 Ago 2014
Categorie
Scopri di più su Get Started with MATLAB in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!