Effacer les filtres
Effacer les filtres

I have 98x3 matrix with only 7 unique rows of values which are output of some simulation. How do I extract that? I tried Unique function but am not getting unique rows. Below is the original matrix A and matrix after using unique function B.

1 vue (au cours des 30 derniers jours)
A
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
1.0000 -1.0000 0.0500
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
1.5000 -0.0000 0.0500
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
1.0000 1.0000 0.0500
1.0000 1.0000 0.0500
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
-1.0000 1.0000 0.0500
-1.0000 1.0000 0.0500
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
-1.5000 -0.0000 0.0500
-1.5000 -0.0000 0.0500
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
-1.0000 -1.0000 0.0500
-1.0000 -1.0000 0.0500
B=unique(A,'rows')
B
-1.5000 -0.0000 0.0500
-1.5000 -0.0000 0.0500
-1.0000 -1.0000 0.0500
-1.0000 1.0000 0.0500
0 0 0
1.0000 -1.0000 0.0500
1.0000 1.0000 0.0500
1.5000 -0.0000 0.0500

Réponse acceptée

Rik
Rik le 23 Avr 2018
This is probably due to rounding errors caused by the way doubles are stored in computers. You can use uniquetol instead:
B=uniquetol(A,'ByRows',true);
The tolerance defaults to 1e-6 for single-precision inputs and 1e-12 for double-precision inputs. You can also specify your own tolerance instead.
  1 commentaire
akash sonnad
akash sonnad le 25 Avr 2018
Thanks for the hint. Since i was'nt interested in accuracy of data so rounded it off till 3rd decimal digits. It helps !!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by