Data arrangmnet of combining 2 variables

1 Ansicht (letzte 30 Tage)
Avishka G
Avishka G am 2 Apr. 2020
Kommentiert: Ameer Hamza am 3 Apr. 2020
I have 3 variables (X,Y,V) which I want to combine into one, in a way that the first column of X,Y and V are columned next to each other and then the second column of X,Y,V are next to each other and so on.
An example of the code:
V=magic(6)
X=magic(6)
Y=magic(5)

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 2 Apr. 2020
Try this
X = ones(6).*(1:6);
Y = 2*ones(6).*(1:6);
Z = 3*ones(6).*(1:6);
M = permute(cat(3,X,Y,Z), [1 3 2]);
M = reshape(M, 6, []);
  2 Kommentare
Avishka G
Avishka G am 3 Apr. 2020
it work fine thanks!
Ameer Hamza
Ameer Hamza am 3 Apr. 2020
Glad to be of help.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

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