Extracting a number from certain line of .txt file
1 次查看(过去 30 天)
显示 更早的评论
Hi everyone I have big .txt file and I want to extract the certain value
How can I extract and print the value written after "COLLAPSE MULTIPLIER=" into file.
2 个评论
采纳的回答
Paolo
2018-6-19
For the values which follow "COLLAPSE MULTIPLIER = ", you can simply use a positive lookbehind which checks for the pattern you indicated.
file = fileread('collapsemultiplier.txt');
match = regexp(file,'(?<=COLLAPSE\sMULTIPLIER\s=\s)(\d*.?\d*)','match');
match =
1×10 cell array
Columns 1 through 6
{'1.945'} {'3.594'} {'4.648'} {'5.361'} {'5.898'} {'6.360'}
Columns 7 through 10
{'6.727'} {'7.038'} {'7.337'} {'7.584'}
7 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!