# How to find repeated elements , numbers and corresponding values?

4 visualizzazioni (ultimi 30 giorni)
Cladio Andrea il 2 Mar 2015
Risposto: Andrei Bobrov il 2 Mar 2015
Hello everyone, i have matrices like that:
1701595 1000
1704973 1000
1704973 1000
1713813 1000
1713812 1000
1713813 1000
1718216 1000
1718217 1000
1721276 1000
1730543 1000
1730544 1000
1733979 1000
1733978 1000
1754675 1000
1755167 1000
1764620 1000
1767147 1000
1767147 1000
1767146 1000
1768028 1000
1778080 1000
1792257 1000
1792257 1000
1803714 1000
1815437 1000
1820059 1000
1826840 1000
1828145 1000
as you see, there are some same elements in the first row, what i want is , as a third row is that if an element is repeated in the first row, delete the first one(s) row, just keep the last row and write how many times that element is repeated, and as a fourth row, lets say if it is repeated four time than the fourth column will be 4000 for this element, please can you give me an idea about how to do that?
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
You seem to be mixing up rows and columns in your question in numerous places, or I'm just misunderstanding what you want.
I assume you means there are some same elements in the first column and that you wish to put 4000 in the second column for a row that represents the 4th row with an identical value in the 1st column?

Accedi per commentare.

### Risposte (1)

Andrei Bobrov il 2 Mar 2015
a = [1701595 1000
1704973 1000
1704973 1000
1713813 1000
1713812 1000
1713813 1000
1718216 1000
1718217 1000
1721276 1000
1730543 1000
1730544 1000
1733979 1000
1733978 1000
1754675 1000
1755167 1000
1764620 1000
1767147 1000
1767147 1000
1767146 1000
1768028 1000
1778080 1000
1792257 1000
1792257 1000
1803714 1000
1815437 1000
1820059 1000
1826840 1000
1828145 1000];
[~,b1,c1] = unique(a(:,1),'stable');
out = [a(b1,:) accumarray(c1,1)];
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Axis Labels in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by