How to find unique elements in a vector without using unique or find?
Mostrar comentarios más antiguos
I have A=randi(100,1,100); How can I find unique values in array and show them without using unique() and find() .
5 comentarios
Walter Roberson
el 23 de Oct. de 2016
The question was about how to find unique elements in a vector without using unique() or one other standard call (find?)
Massimo Zanetti
el 24 de Oct. de 2016
Yes, maybe "trackable" homeworks?? :)
Jan
el 24 de Oct. de 2016
At least the OP mentioned, that he is sorry about the deleting.
John D'Errico
el 24 de Oct. de 2016
Yes. It CAN be done using basic MATLAB statements.
For example, using sort, then diff and find will make it absolutely trivial. And if you cannot use unique, then sort, diff and find are off limits too.
But this is homework. You need to do your homework. There is simply no reason for this question under any other circumstances. It was assigned to you, for you to learn. If we doit for you then you learn nothing but how to get others to do your work.
Rena Berman
el 20 de En. de 2017
Editada: Image Analyst
el 11 de Dic. de 2017
(Answers Dev) Restored Question.
I have
A=randi(100,1,100);
How can I find unique values in array and show them without using unique() and find() .
Respuesta aceptada
Más respuestas (1)
You can do this with for and if:
suppose you have the numbers in x
and want to generate the unique numbers in xu
pick the first number of x, this is your first unique number in xu
now run through all the number in x
check if it is in xu
if so, proceed with the next number of x
else, add the number to your unique numbers x
Voilá
This is a possible algorithm, and it is up to you to implement it, to learn something.
1 comentario
Trevor Badji
el 24 de Oct. de 2016
Categorías
Más información sobre MATLAB Coder en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!