Performing a function (such as standard deviation) on groups of data

1 visualizzazione (ultimi 30 giorni)
I have created runs that are based on if data is present. See below for the "raw data example". What i want to do is create a new matrix/table that is filled with analyzed data for each run. For example, I want to create a table filled with the standard deviation of each run, which would look similar to "Analyzed Example". Note that the std for run 1 was from lines 4 to 8. I am unsure if I explained this well enough and I would appreciate any assistance/guidance. Thank you.
Analyzed Example
Raw Data Example

Risposte (1)

madhan ravi
madhan ravi il 7 Lug 2020
Modificato: madhan ravi il 7 Lug 2020
[~, ~, c]= unique(Run, 'stable'); % Run is without zeros
STD = accumarray(c, (1:numel(Data)).', [], @std)
%or
STD = splitapply(@std, Data, findgroups(Run))
%or
STD = grpstats(array2table([Run,Data], 'VariableNames',{'Run', 'Data'} ),'Run','std')
%or
T = array2table([Run,Data], 'VariableNames',{'Run', 'Data'} );
STD = groupsummary(T, 'Run','std'

Categorie

Scopri di più su Tables 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