simple formula to remove rows with repeated values in N x 2 matrix
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
LO
el 12 de Abr. de 2019
Respondida: Star Strider
el 12 de Abr. de 2019
I have a set of XY coordinates in a N x 2 matrix
I would like to remove those pairs in which X values are the same
I do not want to use the "unique" function (I tried it but it does not work, perhaps my X values are not exactly the same although they look like they are) and I would not like to use a complicated series of commands...
the code I am using now is
X1=ampl1;
Y1=width1;
A1=[X1;Y1]';
[UniXY,Index]=unique(A1,'rows');
DupIndex=setdiff(1:size(A1,1),Index);
A1(DupIndex,:)=[];
ampl1=A1(:,1)';
widths1=A1(:,2)';
it seems to work for discrete finite values but somehow for my case, it does not work.
I would not mind to round my values but I would like to keep at least 2-3 decimals
0 comentarios
Respuesta aceptada
Star Strider
el 12 de Abr. de 2019
The uniquetol (link) function (introduced in R2015a) allows you to set a tolerance. Also, setdiff does not have a tolerance option, although ismembertol does.
See if those do what you want.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!