Use combvec for pairs of values

4 Ansichten (letzte 30 Tage)
Lucas campos
Lucas campos am 30 Okt. 2021
Beantwortet: DGM am 30 Okt. 2021
Hello,
I have a matrix (20 x 2) .
I would like to create 4 possible combinations of each pair of values present on each row of this matrix into a new matrix with 8 columns.
Basically, I would like to use combvec but instead of using scalars, I would be using pairs of values.
Any ideas?
Tnks

Antworten (2)

M.MUSBA Elhadid
M.MUSBA Elhadid am 30 Okt. 2021
a = repmat(a,2,4);

DGM
DGM am 30 Okt. 2021
If there's only two columns, what's wrong with just doing
A = randi(9,20,2)
A = 20×2
8 4 8 6 7 8 4 1 7 6 3 8 1 5 5 6 1 3 9 5
B = A(:,[1 1 1 2 2 1 2 2])
B = 20×8
8 8 8 4 4 8 4 4 8 8 8 6 6 8 6 6 7 7 7 8 8 7 8 8 4 4 4 1 1 4 1 1 7 7 7 6 6 7 6 6 3 3 3 8 8 3 8 8 1 1 1 5 5 1 5 5 5 5 5 6 6 5 6 6 1 1 1 3 3 1 3 3 9 9 9 5 5 9 5 5

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by