how to print a specific potion of a text file

조회 수: 6 (최근 30일)
Ayushi Saxena
Ayushi Saxena 2015년 12월 29일
댓글: Ayushi Saxena 2015년 12월 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

채택된 답변

Walter Roberson
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
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?
Ayushi Saxena
Ayushi Saxena 2015년 12월 30일
thanks.. it worked .. basically i have a pdf file which i have converted into txt format so on that basis i was trying to do that.....

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by