How to extract number from cell array?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Heidi Mäkitalo
le 13 Juin 2019
Commenté : Heidi Mäkitalo
le 2 Juil 2019
I have a cell array that contains only the following text: 'Interval: 0.02 sec'. How can I extract the number 0.02 from the cell, to be used in calculations?
0 commentaires
Réponse acceptée
madhan ravi
le 13 Juin 2019
cellfun(@(x) sscanf(x,'Interval: %f'),c,'un',0) % assuming follows the same pattern , turn 0 to 1 if it’s a scalar output.
2 commentaires
madhan ravi
le 13 Juin 2019
Modifié(e) : madhan ravi
le 13 Juin 2019
OR
str2double(regexp(c,'\d+[\.]?\d*','match','once')) % where c is your cell array
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Cell Arrays 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!