Calculating the median for each column based on unique values in 1st column

2 views (last 30 days)
Hi all,
I've been search for a solution to this for a while now, and while i can find various ways that get me close, I cant seem to work out exactly what I want. I have a table of various sound metrics for some recordings. The table is 384744x5 with the 1st column being the start time of the recording (duplicated 24 times), and the other 4 are different values. Each file has 24 values taken from it and i want to produce a median value for each column, 2:5 for the 24 values. Ideally the output will be a 16031x5 table with column 1 being unique values of the start time, and columns 2-5 the median values.

Accepted Answer

Thomas Webber
Thomas Webber on 9 Jul 2020
I think I have managed to solve this problem.
Where UTC is the column of variables to group medians by, RMS, ZeroPEak, PeakPEak and SEL are columns to find median of.
omedian = @(x) median(x,'omitnan');
medianByRec = varfun(omedian,Filtered,'GroupingVariables','UTC',...
'InputVariables',{'RMS','ZeroPeak', 'PeakPeak', 'SEL'})

More Answers (0)

Categories

Find more on Tables 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!