我有一个〜100000/2矩阵。我想浏览一下各列,对每个垂直相邻的值求平均值,然后将该值插入两个值之间。例如...
1 2 3 4 4 6 7 8 会成为
1 2 2 3 3 4 3.5 5 4 6 5.5 7 7 8 我不确定在matlab中是否有简洁的方法可以做到这一点。我看了一下
http://www.mathworks.com/matlabcentral/fileexchange/9984,但似乎在特定点将矩阵中的所有行插入到另一行中。显然它仍然可以使用,但是只是想知道是否有更简单的方法。
任何帮助表示赞赏,谢谢。
回答:
未经测试:
% Take the mean of adjacent pairs x_mean = ([x; 0 0] + [0 0; x]) / 2; % Interleave the two matrices y = kron(x, [1;0]) + kron(x_mean(1:end-1,:), [0;1]);
更多&回答...