# Getting rid of duplicate values in pairwise matrix to obtain single vector?

1 Ansicht (letzte 30 Tage)
Erik J am 25 Feb. 2020
Kommentiert: Erik J am 26 Feb. 2020
Hello. I have a large (11000x11000) matrix of pairwise distances between 11000 points. I need to make a histogram of these distances. However, each vaue appears twice (e.g., in 2,2, 3,3 etc). How can I eliminate these duplicates to obtain a single vector of all unique values?
Thank you all so much.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Rik am 25 Feb. 2020
The easiest is the pragmatic approach: get the counts with histcounts and divide that by 2.
X=randn(100,1);
[N,edges] = histcounts(X);
N=N/2;
centers=edges(2:end)-0.5*diff(edges(1:2));
bar(centers,N)
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Erik J am 26 Feb. 2020
This makes total sense. Thank you!

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

R2019b

### Community Treasure Hunt

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

Start Hunting!

Translated by