How can I extract the last rows of specific columns of a text file
Show older comments
Please, I have a text file contains three columns I need to extract the last rows of the third and forth columns only and write them into a text file. for example, from the text file attached the result needs to be written in a text file. it should return:
1.87 36
157 35
1.88 37
1.36 48
1.73 78
1.99 100
Many thanks
2 Comments
Jan
on 19 Oct 2015
There is no attached file.
Accepted Answer
More Answers (1)
TastyPastry
on 19 Oct 2015
Open the file
fid = fopen('your file name.txt');
Skip the header
fgetl(fid);
Use textscan()
myOutput = textscan(fid,'%d %d %d');
It will return a cell array containing all the numerical data, just ignore the first two columns.
1 Comment
Categories
Find more on Large Files and Big Data 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!