How to find the mean after every n columns?
显示 更早的评论
Hi all
In order to find the mean column-wise, I know that we should code as follows:
Answer = nanmean(mymatrix,2); %%mymatrix has many columns %%Answer gives 1 column
Now I have a matrix of size 770 rows x 5760 columns. But I would like to find the mean after EVERY 4 columns and store them in a new matrix. So my final answer matrix will have 770 rows x 1440 columns. How can I do that? Any help is appreciated!
Thank you.
采纳的回答
更多回答(1 个)
Giorgos Papakonstantinou
2015-3-4
编辑:Giorgos Papakonstantinou
2015-3-4
NewMatrix = mymatrix(:,1:4:end);
Youranswer = nanmean(NewMatrix , 2);
2 个评论
Sean de Wolski
2015-3-4
I think OP wants the mean of the first four columns, mean of the second four columns etc., not skipping 1:3, 5:7.
B.kun
2015-3-4
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!