Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Dear Community
I would like to remove all lines containing zeros from my vector. Please help.
Regards,
Tomek
Solved! Go to Solution.
I have modified my routine from this thread
a bit so it returns the matrix unchanged only if it contains no zeros and returns an error message if every row contains at least one zero. You may change the latter to something like returning a NaN or a 0 or a string.
Nevertheless as already written in the other thread, the used built-in match command has its bugs as it will compare values only with the tolerance given by the system variable TOL (even when using the modifyer; "eq" will do the same as "near") which can led to some unexpected and undesirable effects. I show an example below.
So I would rather use the second function given here for better reliability:
Worksheet in Format P4 attached.
I have modified my routine from this thread
a bit so it returns the matrix unchanged only if it contains no zeros and returns an error message if every row contains at least one zero. You may change the latter to something like returning a NaN or a 0 or a string.
Nevertheless as already written in the other thread, the used built-in match command has its bugs as it will compare values only with the tolerance given by the system variable TOL (even when using the modifyer; "eq" will do the same as "near") which can led to some unexpected and undesirable effects. I show an example below.
So I would rather use the second function given here for better reliability:
Worksheet in Format P4 attached.