how to use cell function to convert string to number
Mostra commenti meno recenti
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?
Risposta accettata
Più risposte (1)
Azzi Abdelmalek
il 11 Giu 2015
a = { 'a' '0' ; 'b' '1' ; 'c' '2' ; 'd' '3'}
a(:,2)=cellfun(@str2double,a(:,2),'un',0)
2 Commenti
Supraja Murali
il 20 Dic 2018
Can you explain what 'un' and '0' are in the answer above?
madhan ravi
il 20 Dic 2018
un-> UniformOutput 0-> false
Categorie
Scopri di più su Characters and Strings in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!