How to form a matrix from a given matrix?

I have a matrix as
A=[1 3
5 4]
I want to form a matrix with all possible pairs for example
B=[1 3 4
1 3 5
3 4 5]
where, B is obtained from A with all elements of A and formed a 3 collumn matrix.
please please help me....

 採用された回答

Guillaume
Guillaume 2015 年 7 月 14 日

1 投票

A = [1 3; 5 4]; %Note that it does not make sense to have A as a matrix.
%A = [1 3 4 5] would make more sense.
B = nchoosek(A(:), 3)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

2015 年 7 月 14 日

回答済み:

2015 年 7 月 14 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by