Text file row-column formatting

1 view (last 30 days)
I have this text file, It contains 3 columns. I want to remove all those rows whose third column element is 0...
So, how to do it..?

Accepted Answer

Walter Roberson
Walter Roberson on 4 Dec 2012
Edited: Walter Roberson on 4 Dec 2012
YourData = load('3d.txt');
YourData(YourData(:,3) == 0, :) = [];
save('New3d.txt', 'YourData', '-ascii');
  2 Comments
Lalit Patil
Lalit Patil on 4 Dec 2012
It shows this kind of error.
??? Index of element to remove exceeds matrix dimensions.
Walter Roberson
Walter Roberson on 4 Dec 2012
Sorry I have edited the above to fix the problem.

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB 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!