Performing a function (such as standard deviation) on groups of data
1 回表示 (過去 30 日間)
古いコメントを表示
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

0 件のコメント
回答 (1 件)
madhan ravi
2020 年 7 月 7 日
編集済み: madhan ravi
2020 年 7 月 7 日
[~, ~, 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'
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!