矩阵的合并平均值
我有一个包含 n 行和 n 列的矩阵,我想一次对 10 行进行平均分箱,这意味着最终我留下一个大小为 n/10×n 的矩阵。我添加了 matlab 库并尝试了以下代码:
nRemove = rem(size(a,1),10);
a = a(1:end-nRemove,:)
Avg = mean(reshape(a,10,[],n));
AvgF = squeeze(Avg);
但它不起作用,我应该使用哪些代码?
谢谢!!
I have a matrix with n rows and n columns and I would like to do binning average 10 rows at a time, which means in the end I am left with a matrix of size n/10-by-n. I added the matlab library and tried the following code:
nRemove = rem(size(a,1),10);
a = a(1:end-nRemove,:)
Avg = mean(reshape(a,10,[],n));
AvgF = squeeze(Avg);
but it didn't work, which code/codes should i use?
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是另一种方法:
这会导致
Here is another way to do it:
which results in
您需要转置操作来重新定向结果。人们经常需要在“应用”操作后执行此操作。
You need the transpose operation to re-orient the result. One often needs to do so after an 'apply' operation.