Creating subsets from a matrix and averaging them separately
显示 更早的评论
I have a 43,692x1 matrix that I need to divide into subsets of 6x1 every 6 rows (i.e. a total of 7,282 subsets). In other words, I need to divide the original matrix every 6 rows. Then, I need to take the average of the three smallest values from each subset. Finally, I would need to average all the resulting values from the last operation to obtain a single value at the end. What would you suggest is the best approach for this challenge?
回答(1 个)
Image Analyst
2015-11-18
Sounds like homework, so I'll just give you the steps: reshape into 6 columns, sort the rows horizontally, extract the left most 3 columns to get the smallest 3 numbers in each row. Take the mean:
reshapedData = reshape(data, [......]);
sortedData = sort(reshapedData, ......., '.....');
result = mean(sortedData(:,3), 2);
See if you can finish it - you're a smart engineer so I think you can do it.
2 个评论
Richard Joisce
2022-2-28
"See if you can finish it - you're a smart engineer so I think you can do it"
AKA "I cba to work it out properly".
An indredibly unhelpful response for future readers smh
Image Analyst
2022-2-28
Perhaps this reply would have offered additional help.
Note, we can't do the whole thing for them if it's homework but we can give them hints and encourage them to finish it themselves.
类别
在 帮助中心 和 File Exchange 中查找有关 Time Series Events 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!