how to combine two matrix?

2 Ansichten (letzte 30 Tage)
Triveni
Triveni am 9 Feb. 2016
Kommentiert: Walter Roberson am 9 Feb. 2016
example1=[25 20 30 40 50 60 70 80 90];
ex_perm = reshape((perms(example1))', 1,size(example1,2),[]);
I want [example1; ex_perm] format.
Means 1*9*362881 Matrix.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 9 Feb. 2016
That is not combining two matrices. The code you show looks like it would work. An easier way of doing that would be
ex_perm = permute(perms(example1), [3 2 1]);
  2 Kommentare
Triveni
Triveni am 9 Feb. 2016
Sir, I need to combine it urgently. please help me...because my initial guess is works fine than other permutations.
Walter Roberson
Walter Roberson am 9 Feb. 2016
Ah, I did not notice that you wanted another copy of example1 in there. Note that the original form of example1 will already be included in the list, so only do this if you do not mind having a duplicate entry.
One way:
permute([example1; perms(example1)], [3 2 1])
Another:
ex_perm = permute(perms(example1), [3 2 1]);
result = cat(3, example1, ex_perm);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by