Clear Filters
Clear Filters

a problem with unique command

1 view (last 30 days)
Mnr
Mnr on 4 Apr 2016
Edited: Walter Roberson on 5 Apr 2016
Hello all,
I have an mx1 vector A, that is ordered in an ascending manner. I would like to find unique elements of this vector, however, by using "unique" command, I am getting the same output as A. Can anybody tell me how I can resolve this issue? I think it has to be done with matlab precision, but I do not know how to fix it.
Thanks!
  2 Comments
James Tursa
James Tursa on 4 Apr 2016
Please post a short example showing A and what you want for output, and how you are currently using unique.
Mnr
Mnr on 4 Apr 2016
Edited: Walter Roberson on 5 Apr 2016
when I use "format long"
A=[1.414213562645795
1.414213562645985
1.414213562645985
1.414213562646871
1.414213562646871
1.553773974242559
1.553773974242559
1.553773974242644]
and I use unique(A), that's why I get the same output as A, while I need matlab to consider A as
[1.414
1.414
1.414
1.414
1.414
1.553
1.553
1.553]
so that the output to unique(A) be [1.414 1.553]

Sign in to comment.

Accepted Answer

Steven Lord
Steven Lord on 4 Apr 2016
Use uniquetol with an appropriate tolerance or discretize your data.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!