MATLAB Answers


Text file row-column formatting

Asked by Lalit Patil on 4 Dec 2012

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



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');


It shows this kind of error.

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

Sorry I have edited the above to fix the problem.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!