I have table T and have added a variable var3. The new variable is initiated empty. When I try to add data to it later, I get the following error.
Conversion to cell from double is not possible.
When I create the variable, how can I change the default data type from cell to double (or any other data type)?

댓글 수: 1

How did you add the new var3 column to the table variable? And how did you try to add data to that column, and what kind of data was it (strings, or numbers)?

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

 채택된 답변

Bryan Wilson
Bryan Wilson 2016년 11월 15일

0 개 추천

OK, I figured out where I went wrong. I thought I was initiating it as a generic default type, but it was actually cell.
%For cell data type
T.Var3 = repmat({''},size(T,1),1);
%For numeric data type
T.Var3 = repmat([],size(T,1),1);

댓글 수: 1

Depending on what you're doing, it might be better to start with a 0x1 in the numeric case. So
T.Var3 = zeros(height(T),1);

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

제품

질문:

2016년 11월 15일

댓글:

2016년 11월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by