I am doing some numerical computations and a few iterations return values that are obviously incorrect (some numerical integration problem, I suppose.). I have managed to set these values to zero but this does not goes well with the ListLinePlot I'm making. So, given this context, my problem is the following:
I have a nX2 matrix where n is a fairly large number. A few elements in column 2 are zero and I want to delete them. If there was only one zero element I would identify the position j of the zero and use Delete[matrix,j]. Since I have more than one of these I've been using
For[j = 1, j <= Length[matrix], j = j + 1,
If[matrix[[j, 2]] == 0, matrix = Delete[matrix, j]]
]
The problem is that this routine only deletes the few first lines with zeros and then stop doing that. I imagine it has something to do with Length[matrix] being changed, but I'm not sure. Could ou help me, please?
Thank you very much.
Comments
Post a Comment