Find the higher frequency for nearest value in column

4 views (last 30 days)
Dear Colleagues, Could any body help me in the bellow code
x=[119.499;-0.192;-0.008;0.006;-0.398;-0.046;-0.028;0.104;-0.019;-0.003] In my matrix x, I want to retrieve the value which is higher in frequency with their nearest value. For instance, no value is duplicated, so the common value in my matrix to be closest with most of values

Accepted Answer

Thorsten
Thorsten on 2 Dec 2014
[X1 X2] = meshgrid(x, x');
D = sqrt((X1 - X2).^2);
x_closedtoall = X1(1, find(sum(D) == min(sum(D))))

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!