How to convert numbers in cell array into double?

2 vues (au cours des 30 derniers jours)
Abhinav
Abhinav le 23 Août 2014
Commenté : Star Strider le 23 Août 2014
I have a cell array like a = '22 16 55.40', which is dMS values, how to separate these three numbers into three cells into numeric array as follows:-
a = '22 16 55.40' to b = [22 16 55.40]. Any help is greatly appreciated.

Réponse acceptée

Star Strider
Star Strider le 23 Août 2014
The textscan function works:
a = {'22 16 55.40'};
b = textscan(char(a), '%f %f %f')
produces:
b =
[22.0000e+000] [16.0000e+000] [55.4000e+000]
with b being a (1x3) cell array.
  2 commentaires
Abhinav
Abhinav le 23 Août 2014
Thanks a lot!
Star Strider
Star Strider le 23 Août 2014
My pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by