how to print a specific potion of a text file
1 次查看(过去 30 天)
显示 更早的评论
hi... i have a text file which has different headings like 1. introduction 2. circuit analysis etc... i want to display all the lines lying between these headings 1 & 2
0 个评论
采纳的回答
Walter Roberson
2015-12-29
filecontent = fileread('YourFile.txt');
h1pos = strfind(filecontent, '1. introduction');
h2pos = strfind(filecontent, '2. circuit analysis');
disp( filecontent(h1pos(1) : h2pos(1)-1) );
4 个评论
Walter Roberson
2015-12-30
output = filecontent(h1pos(1) : h2pos(1)-1);
Note that this will be a single string that includes newline characters and possibly carriage return characters as well. What form are you hoping for considering you have multiple lines?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mix Analog and Digital Signals 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!