Which is the simplest way to create neighbourhood pairs?
1 次查看(过去 30 天)
显示 更早的评论
from [1,2,3,7,8,9] to [1 2; 2 3; 3 7; 7 8; 8 9]
0 个评论
回答(2 个)
Radha Krishna Maddukuri
2015-4-24
编辑:Radha Krishna Maddukuri
2015-4-24
I hope this helps.
B = zeros(numel(A)-1,2);
for i =1:1:(numel(A)-1)
B(i,:) = [A(i) A(i+1)];
end
0 个评论
Andrei Bobrov
2015-4-24
编辑:Andrei Bobrov
2015-4-24
hankel(a(1:end-1),a(end-1:end))
or
[a(1:end-1)', a(1:end-1)'+1]
or
a1 = a(1:end-1)
bsxfun(@plus,a1(:),[0 1])
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numeric Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!