Mixed data types cell to string

Using xlsread I read the a spreadsheet
[ndata, text, alldata] = xlsread(filename);
One cloumn of alldata is a mixed data types as shown below (strings and integers). As I wish to use it for further analysis, is it possible to convert all this cell to be strings?
Thanks.
Cell output:
'NoGroup'
'NoGroup'
'NoGroup'
[1]
[1]
[1]
[2]
[2]
[2]
[2]
[2]
[2]
'Group3'
'Group3'
'Group3'

 채택된 답변

Jan
Jan 2013년 4월 10일

0 개 추천

C = {'NoGroup', 1; 2; 'Group3'};
for iC = 1:numel(C)
if ~ischar(C{iC});
C{iC} = num2str(C{iC});
end
end
There are alternatives like cellfun('isclass', C, 'char') or sprintf('%g', C[iC}).

추가 답변 (0개)

카테고리

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

질문:

2013년 4월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by