# what does c(:).' mean? c should be a vector

조회 수: 15 (최근 30일)
Yuji Zhang 2014년 8월 24일
댓글: Yuji Zhang 2014년 8월 25일
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!

댓글을 달려면 로그인하십시오.

### 채택된 답변

Matz Johansson Bergström 2014년 8월 24일
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;
tmp(:).'
which gives you each complex number in a row vector, compared to
tmp(:)'
which is giving you a row vector of the complex conjugate of each element.
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Yuji Zhang 2014년 8월 24일
Ahh i see! Thanks Matz!

댓글을 달려면 로그인하십시오.

### 추가 답변 (1개)

Roger Stafford 2014년 8월 24일
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이전 댓글 2개 표시이전 댓글 2개 숨기기
Roger Stafford 2014년 8월 24일
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 2014년 8월 25일
Ahh I see that! So the dot has two meanings! Thanks a lot for your help Roger!

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by