- I'm not sure I understand what you mean. If I create a cell array, it displays like this in the command window.
character array vs cell array empty cells
조회 수: 4 (최근 30일)
이전 댓글 표시
I have an array, which is identified by iscell() as a cell array but behaves like a character array:
'jan 7' '2' '' '2.5'
I have 2 questions: 1) why is it not displayed in the console as:
['jan 7'] ['2'] [''] ['2.5']
2) how can i change all [''] cells to [] 3) when trying to create a table with this data I am getting the message: You may have intended to create a table with one row from one or more variables that are character strings. Consider using cell arrays of strings rather than character arrays. Alternatively, create a cell array with one row, and convert that to a table using CELL2TABLE.
Is there a way to convert this array to be easily usable for my table?
Appreciate the help, and I realize this is a pretty basic question but help is appreciated
Thanks,
Will
댓글 수: 0
채택된 답변
Marc Jakobi
2016년 10월 15일
편집: Marc Jakobi
2016년 10월 15일
That's 3 questions ;)
C = { 'jan 7' '2' '' '2.5'}
C =
1×4 cell array
'jan 7' '2' '' '2.5'
which is perfectly normal.
2. I would either create an empty copy of C and move the other values over
D = cell(size(C));
tf = ~ismember(C,'');
D(tf) = C(tf); % this will create an array {'jan 7' '2' [] '2.5'}
or alternatively just remove the cells from C:
C(~ismember(C,'')) = []; % this will create an array {'jan 7' '2' '2.5'}
3. Which function are you trying to use to create the table? If I use
T = cell2table(C);
it works just fine.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!