View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Average and remove duplicates from a matrix

3.5 | 2 ratings Rate this file 3 Downloads (last 30 days) File Size: 1.39 KB File ID: #34952 Version: 1.0

Average and remove duplicates from a matrix



This function averages out duplicate values in a matrix and removes the duplicates

| Watch this File

File Information

This function finds duplicate values along the first column of a matrix, averages the remaining rows, and removes the duplicate rows.

MATLAB release MATLAB 7.9 (R2009b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
01 May 2012 John D'Errico

John D'Errico (view profile)

01 May 2012 John D'Errico

John D'Errico (view profile)

Incredibly slow.

X = round(rand(1e6,1)*10000);

Elapsed time is 58.442939 seconds.

Elapsed time is 0.609666 seconds.

And it is not terribly useful, since it

1. Looks for exact replicates, with no capability for a tolerance.

2. Allows the capability to average only. If you want to compute instead the sum, or max, min, harmonic mean, median, geometric mean, standard deviation, etc., you are out of luck.

There is no H1 line, merely a statement of the author's name and e-mail address. That means the lookfor tool is disabled when you forget what the name of this tool is next year.

I'd suggest a tool that offers everything this does and far more, allowing you to compute any aggregative measure, has better help, an H1 line, and is seriously faster.

Comment only
01 May 2012 rasam aliazizi

Thank you, this is exctly what i was looking for.

08 Feb 2012 Jos (10584)

Jos (10584) (view profile)

This might be useful to some. However, you should a look at accumarray:

[u,i,j] = unique(A(:,1)) ;
A_avg_dup = [j, accumarray(j,A(:,2),[],@mean)] ;

In addition, you might revise your help section, so that it mimics ML standards (H1 line, used by LOOKFOR, a SEE ALSO line). Take a look at the help of any basic ML function for some inspiration.

Comment only

Contact us