필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
Hi, How can I extract numbers out of this .mat file ? Thanks.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 17일
편집: Azzi Abdelmalek 2015년 7월 17일
a=regexp(text,'(?<==)\d+(.)?(\d+)?','match','once')
id=~cellfun(@isempty,a(:,1))
a=str2double(a(id))
  댓글 수: 2
Karthik
Karthik 2015년 7월 17일
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 2015년 7월 17일
편집: Stephen23 2015년 7월 17일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by