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!