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에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!