determine the limit of txt file while using regexp
Show older comments
content = fileread( 'trial.txt' ) ;
matches = regexp( content, '[-\d\.]+(?=-\d)', 'match' ) ;
data = str2double( matches );
% With above commands, I extract the specific numeric values in the attached file. But I need to limit this search from %beginning to "START OF RMS MAP" (line 32, but this number is variable) not all lines. How can I set the this last line while I'm using regexp.
2 Comments
Stephen's approach is the best, but if you can't figure out how to adapt it to your case and need to work out a solution quickly, you can always do
content = strsplit( fileread( 'trial.txt' ), 'START OF RMS MAP' ) ;
data = str2double( regexp( content{1}, '[-\d\.]+(?=-\d)', 'match' )) ;
PS: if this question is still about extracting only the numbers mentioned in this thread, you should have made it clear initially, because Stephen wrote a complete solution for extracting all numbers within the section that you mention.
sermet
on 15 Sep 2015
Accepted Answer
More Answers (0)
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!