how to use cell function to convert string to number
2 views (last 30 days)
Show older comments
Gopalakrishnan venkatesan
on 11 Jun 2015
Commented: madhan ravi
on 20 Dec 2018
I have a cell array a = { 'a' '0' ; 'b' '1' ; 'c' '2' ; 'd' '3'}
so a = 'a' '0'
'b''1'
'c''2'
how can I convert the second column from string to number and should retain the cell array?
0 Comments
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 11 Jun 2015
a = { 'a' '0' ; 'b' '1' ; 'c' '2' ; 'd' '3'}
a(:,2)=cellfun(@str2double,a(:,2),'un',0)
2 Comments
See Also
Categories
Find more on Data Type Conversion 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!