MATLAB Answers

Text file row-column formatting

Asked by Lalit Patil on 4 Dec 2012

http://speedy.sh/BTw3z/3d.txt

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..?

  0 Comments

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson
on 4 Dec 2012
Edited by Walter Roberson
on 4 Dec 2012
 Accepted answer
YourData = load('3d.txt');
YourData(YourData(:,3) == 0, :) = [];
save('New3d.txt', 'YourData', '-ascii');

  2 Comments

Lalit Patil on 4 Dec 2012

It shows this kind of error.

??? Index of element to remove exceeds matrix dimensions.

Walter Roberson
on 4 Dec 2012

Sorry I have edited the above to fix the problem.


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today