data sorting for finding average and standard deviation
1 view (last 30 days)
Show older comments
I have a .csv file that contains data for different speakers (s1, s2, s3, s4,s 5, s6, and s8) and words (a and i). Please see attached the input.csv. I want to create a .csv file that will calculate the average and standard deviation for each speaker and word and save it as my output.csv. Please note that the no. of repetitions of each speaker is different. It contains five repetitions but can vary. The output.csv is attached the way I want to sort out the data. The 1st block contains the average of the data for word a, the second block contains the standard deviation for word a, the third block contains the average for word i, and the fourth block contains the standard deviation for word b.
Any helpor suggestions would really be helpful.
Thanks
2 Comments
KALYAN ACHARJYA
on 8 Nov 2022
Edited: KALYAN ACHARJYA
on 8 Nov 2022
Can you share the data in more simplify way ( Just sample data)?
Answers (1)
Cris LaPierre
on 8 Nov 2022
I would look into using groupsummary. I'll let you worry about getting the output formatted the way you want, but here's how I would do it.
file = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1185463/input.csv';
in = readtable(file, ReadVariableNames=true)
out = groupsummary(in,["word","speaker"],["mean","std"],["x0" "x25" "x50" "x75" "x100" "x_10"])
0 Comments
See Also
Categories
Find more on Shifting and Sorting 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!