How would I create my own 'unique' function without using the built in unique?
Ältere Kommentare anzeigen
I understand that the built in Unique function is stating that whatever function you define as unique is the same data set but without repetitions.
should I create a function file such as
function[unique,c] = myuni_1(A)
rows(A)= size(A,1);
columns(A) = size(A,2);
and then proceed to define the rows and columns as itself? I'm a bit confused here.
3 Kommentare
the cyclist
am 29 Apr. 2014
Why would you want to do this? Is this a homework assignment?
Alexander
am 29 Apr. 2014
Akzeptierte Antwort
Weitere Antworten (2)
Walter Roberson
am 29 Apr. 2014
0 Stimmen
Suppose you have two "bags", A and B. Start with A empty.
If B is empty, you are done and A holds the unique values. Otherwise, take one one item, C, out of B (removing it from B). Is there already a copy of C in A? If there is, then throw away C. Otherwise, add C to A. Now restart this paragraph.
1 Kommentar
Alexander
am 30 Apr. 2014
Sean de Wolski
am 30 Apr. 2014
Bearbeitet: Sean de Wolski
am 30 Apr. 2014
How about this?
x = [1 2 3 3 3 3 2 4 5];
[uv,ia] = intersect(x,x)
Kategorien
Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!