To find the average of values in matrix
2 次查看(过去 30 天)
显示 更早的评论
I have 32 (131X160) matrices. I want to find the average of 5 elements in each matrices and return in (1X32) matrix.
2 个评论
Jan
2021-10-15
How are the 32 matrices stored? As fields of a struct, as cell array, as numerical 3D array?
Which 5 elements are you interested in? How are they given? As indices, logical index or values?
回答(1 个)
Star Strider
2021-10-15
Try something like this (assuming that they are stored as elements of a cell array similar to these) —
C = {randn(131,160), randn(131,160), randn(131,160), randn(131,160), randn(131,160)};
Cm = cellfun(@(x)mean(x(85:90,65)), C)
Experiment with the actual cell array to get differnt results.
.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!