Extract numbers out of a .mat file that has both characters and numbers
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Karthik
il 16 Lug 2015
Modificato: Stephen23
il 17 Lug 2015
Hi, How can I extract numbers out of this .mat file ? Thanks.
0 Commenti
Risposta accettata
Azzi Abdelmalek
il 17 Lug 2015
Modificato: Azzi Abdelmalek
il 17 Lug 2015
a=regexp(text,'(?<==)\d+(.)?(\d+)?','match','once')
id=~cellfun(@isempty,a(:,1))
a=str2double(a(id))
2 Commenti
Stephen23
il 17 Lug 2015
Modificato: Stephen23
il 17 Lug 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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Workspace Variables and MAT Files in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!