Filter löschen
Filter löschen

Extract numbers out of a .mat file that has both characters and numbers

1 Ansicht (letzte 30 Tage)
Hi, How can I extract numbers out of this .mat file ? Thanks.

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 17 Jul. 2015
Bearbeitet: Azzi Abdelmalek am 17 Jul. 2015
a=regexp(text,'(?<==)\d+(.)?(\d+)?','match','once')
id=~cellfun(@isempty,a(:,1))
a=str2double(a(id))
  2 Kommentare
Karthik
Karthik am 17 Jul. 2015
Hi, Thanks. The numbers like 2.3*e-4 are being read as 2.3. Not producing the exact numbers. Can you let me know how to fix it.
Stephen23
Stephen23 am 17 Jul. 2015
Bearbeitet: Stephen23 am 17 Jul. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by