Error when applying cell2mat

조회 수: 7 (최근 30일)
Maria
Maria 2014년 8월 22일
답변: Image Analyst 2014년 8월 23일
I have several columns in a cell array A with double values, and I am applying this very simple formula to get separate variables:
y=cell2mat(ANALLSper(:,2)); %for example
And for somecase ist gives me this error:
Error using cell2mat (line 45)
All contents of the input cell array must be of the same data type.
Does someone know how to solve it? Thank you very much.
  댓글 수: 1
José-Luis
José-Luis 2014년 8월 22일
It means that not everything in that array is what you think it is. Try looking at that array in the editor.

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

채택된 답변

Jan
Jan 2014년 8월 23일
Check it manually:
all(cellfun('isclass', ANALLSper(:,2), 'double'))

추가 답변 (1개)

Image Analyst
Image Analyst 2014년 8월 23일
Maybe you don't even need a cell array. Why deal with that complication if you don't have to and you ultimately want to get a double array anyway. Why not just start off using a double array. A cell array is more flexible but more complicated. If you really want the complication of a cell array, read the FAQ: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by