Extracting data from an unformatted text file
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi, I want to extract certain values from an unformatted text file, in the example I use the regexp function entering the format of the data I want to extract.
(file format)
...
<<<<< Function evaluation summary (I1): 582 total (581 new, 1 duplicate)
<<<<< Best parameters =
31 x1
7 x2
87 x3
83 x4
3 x5
63 x6
5 x7
72 x8
12 x9
51 x10
67 x11
82 x12
81 x13
35 x14
52 x15
13 x16
32 x17
19 x18
73 x19
24 x20
50 x21
71 x22
61 x23
22 x24
23 x25
27 x26
58 x27
77 x28
1 x29
<<<<< Best objective function =
1.0119441809e+00
...
The output does not work because it extracts undesired values.
str = fileread('OUTPUT.out');
expression = '\d*\s\w\w' ;
regexp = regexp(str,expression, 'match');
How can I extract the values with the presented format?
댓글 수: 2
Rik
2021년 4월 30일
You should rename your file to txt and attach it. That way, we can taylor our code to your exact file format.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Data Preparation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!