how to get combination of elements in a matrix in pair order
1 次查看(过去 30 天)
显示 更早的评论
I have a matrix A=[3 5 6 7 8]
i want the output in the form B= [ 3 5
3 6
3 7
3 8
5 3
5 6
5 7
5 8...] like this
0 个评论
采纳的回答
更多回答(1 个)
Andrei Bobrov
2019-7-11
编辑:Andrei Bobrov
2019-7-11
A=[3 5 6 7 8];
[y,x] = ndgrid(A);
B = [x(:),y(:)];
B = B(diff(B,1,2) ~= 0,:);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!