How i can create a n+1 column matrix from n column matrix?

1 visualización (últimos 30 días)
i have a matrix 10*n, for example, let n=3
a= [ 1 2 3
1 2 4
1 2 5
1 3 4
1 3 5
1 4 5
2 3 4
2 3 5
2 4 5
3 4 5]
i want to create another matrix n+1
b=[1 2 3 4
1 2 3 5
1 2 4 5
1 3 4 5
2 3 4 5]
this is obtained from a as
{1 2 3} and from
{1 2 4}
{1 2 3 4} is created, where no pair must repeat and
{1 2 3} or
{1 2 4} or
{2 3 4}
all pair must be present in a or delete that pair.
please please help me.
i want to know how i can obtain a 4 column matrix from 3 column matrix, if i want 5 column from 4 column matrix then where is the main change in code.
please help me.

Respuesta aceptada

Roger Stafford
Roger Stafford el 23 de Abr. de 2015
It looks to me as if you need to use:
b = nchoosek(1:5,4);

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by