Moving mean in matrix using first column
2 次查看(过去 30 天)
显示 更早的评论
I have a matrix:
a = [1 3 5 2 4 6 7 8 10;
4 3 5 2 8 6 7 8 7;
5 8 9 7 2 3 6 1 5]
I would like to calculate the mean of the first column and the next four columns:
[1;4;5] and [3;3;8]
[1;4;5] and [5;5;9]
[1;4;5] and [2;2;7]
[1;4;5] and [4;8;2]
Then I would like to do the same starting for a(:,2) where it also takes the mean with the previous column:
[3;3;8] and [1;4;5]
[3;3;8] and [5;5;9]
[3;3;8] and [2;2;7]
[3;3;8] and [4;8;2]
until I have done this for all the columns. For the last column I would like it to start with the first column of the matrix again after taking the mean with the previous column so:
[10;7;5] and [8;8;1]
[10;7;5] and [1;4;5]
[10;7;5] and [3;3;8]
[10;7;5] and [5;5;9]
Is there a way in which I could use movmean() to achieve this? Or is there a better way?
Thanks
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!