필터 지우기
필터 지우기

Convert class types in table

조회 수: 5 (최근 30일)
AR
AR 2022년 9월 26일
댓글: AR 2022년 9월 28일
I have a table with different variables consisting of different class elements. Call the table T & the variables A1, A2, A3.
So, class(T.A1) is cell, and class of each individual entry in T.A1 is double.
Class(T.A2) is cell, and class of each individual entry in T.A2 is char.
Class(T.A3) is cell, and class of some entries here is double & some others is char. It appears that the char values are all char([]).
For further operations, I need to convert all values in A1 & A3 to numeric (say double). I tried to replace all the char([]) in T.A3 with []. This works & class of each element in T.A3 now reports as double. However, when I further try:
T.A3 = cell2mat(T.A3)
I get the error: "Brace indexing is not supported for variables of this type. Error in cell2mat..." etc.
Please help figure out what may be wrong, and alternatively suggest how to accomplish the above.
  댓글 수: 8
dpb
dpb 2022년 9월 27일
".... I was using the "raw" read-in data which contains a combination of char & double to formulate the table. By instead using the numeric and char outputs separately..."
That implies you were/are using the deprecated xlsread instead of readtable -- I strongly recomend looking at readtable and its boon companion detectImportOptions instead.
AR
AR 2022년 9월 28일
Noted, for future reference. I forget about readtable although I think I have used it in the past.

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

답변 (0개)

카테고리

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

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by