MATLAB Answers

How to out a txt file that contains specific lines from an input text file with vector of line numbers

1 view (last 30 days)
Audrija Bhattacharjee
Audrija Bhattacharjee on 16 Oct 2019
I am trying to out some specific lines plus an extra empty line at the end in a text file. The initial input was a text file and a vector input that has the line numbers of the lines that I am supposed to take out from the input text. for example-
inputs file is in format
1| smart
2| intelligent
3| dumb
4| silly
and vector=[2 3]
the output will be the lines representing the vector number which is
1| intelligent
2| dumb
3|
the last line is gonna be empty. How to do this?

  0 Comments

Sign in to comment.

Answers (1)

Sahithi Kanumarlapudi
Sahithi Kanumarlapudi on 6 Nov 2019
‘newline’ could be used to insert a newline in a text file.
You can refer to a similar problem of reading specified lines from a text file in the following link
For more information on ‘newline’ refer to the following link
Hope this helps!

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!