convert cell array to string
1 view (last 30 days)
Show older comments
Dear all,
I have the matrix
A={ 'EE' [ 1]
'EE' [NaN]
'EE' [NaN]
'EE' '2'
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' '3'
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [ 4]};
I want to convert the values of the last column to strings so as to have
A={ 'EE' '1'
'EE' [NaN]
'EE' [NaN]
'EE' '2'
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' '3'
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' [NaN]
'EE' '4'};
0 Comments
Answers (1)
Azzi Abdelmalek
on 13 Mar 2013
Edited: Azzi Abdelmalek
on 13 Mar 2013
c2=A(:,2)
idx=cellfun(@(x) isnumeric(x)& ~isnan(x),c2)
c2=cellfun(@num2str,c2,'un',0)
A(idx,2)=c2(idx)
0 Comments
See Also
Categories
Find more on Numeric Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!