How to fill a Cellarray with the real components of a matrix

조회 수: 1 (최근 30일)
Paul Nanfah
Paul Nanfah 2015년 9월 12일
댓글: Star Strider 2015년 9월 12일
hi everyone, I have the following matrix and want to create a Cellarray with contents the real component of the Matrix. my code doesnt work:
[m n]=size(Mat);
C=cell(m,n);
for h = 1:m
for l=1:n
C(h,l) = real(Mat(h,l));
end
end
I got the error "Conversion to cell from double is not possible."
thank you in advance

채택된 답변

Star Strider
Star Strider 2015년 9월 12일
Avoid the loop. This works:
C = real(Mat);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by