how to use cell function to convert string to number
古いコメントを表示
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?
採用された回答
その他の回答 (1 件)
Azzi Abdelmalek
2015 年 6 月 11 日
a = { 'a' '0' ; 'b' '1' ; 'c' '2' ; 'd' '3'}
a(:,2)=cellfun(@str2double,a(:,2),'un',0)
2 件のコメント
Supraja Murali
2018 年 12 月 20 日
Can you explain what 'un' and '0' are in the answer above?
madhan ravi
2018 年 12 月 20 日
un-> UniformOutput 0-> false
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!