Extract numbers out of a .mat file that has both characters and numbers
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Karthik
le 16 Juil 2015
Modifié(e) : Stephen23
le 17 Juil 2015
Hi, How can I extract numbers out of this .mat file ? Thanks.
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 17 Juil 2015
Modifié(e) : Azzi Abdelmalek
le 17 Juil 2015
a=regexp(text,'(?<==)\d+(.)?(\d+)?','match','once')
id=~cellfun(@isempty,a(:,1))
a=str2double(a(id))
2 commentaires
Stephen23
le 17 Juil 2015
Modifié(e) : Stephen23
le 17 Juil 2015
Standard scientific notation using "E" syntax does not use any multiplier symbol, so your source data is non-standard and therefore MATLAB does not recognize it. Therefore you basically have two choices:
- Change the source data to use standard E-notation.
- Read the data into MATLAB as strings, and then do some hackery using regexprep before converting to numeric.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Whos 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!