Averaging values in Column B based on serial date in column A
2 次查看(过去 30 天)
显示 更早的评论
Hello
I have an array that looks like:
col A col B
737585 1
737585 2
737585 3
737586 4
737586 5
737586 6
where column A is the serial date and column B is the respective value. I need a for loop that will average the values in col B that have the same serial date as in column A. Thank you!
ex: serial date: 737585 avg: 1+2+3/3 = 2
0 个评论
采纳的回答
Tommy
2020-7-8
Does it need to be a loop? I believe this will work:
groups = findgroups(yourArray(:,1));
avg = splitapply(@mean, yourArray(:,2), groups);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!