From: Andrew McDonald on
Hi all,

I have a set of XYZ data that I am looking to remove duplicate (X,Y) values from. I am currently using the Unique function to remove the duplicate data, however this function does not allow me to specify which data to keep/remove.

Z data that is equal to 0 signifies a dropout of data, so I do not want to keep this data over Z values that are not 0. If the Z data corresponding to the duplicate (X,Y) values is 0, then I want to delete that entry. Otherwise, it doesn't matter which duplicate is deleted. Is there a way to apply a condition like this to the Unique function?

The example data set below shows a sample of what the data looks like before removing the duplicate values.

XYZ_Data = [1 1 10;
1 2 20; <-- Duplicate
1 3 15;
1 2 0; <-- Duplicate
2 1 0;
2 2 14; <-- Duplicate
2 2 15; <-- Duplicate
2 3 20;]

My desired result needs to remove the [1 2 0] entry, and either one of the [2 2 14], [2 2 15] entries. Notice that I do not want to remove the [2 1 0] entry - Z data that is equal to 0 can stay as long as it is not associated with a duplicate (X,Y) value.