Azzera filtri
Azzera filtri

variable positions in matrix

1 visualizzazione (ultimi 30 giorni)
Linden
Linden il 6 Mag 2014
Risposto: Image Analyst il 6 Mag 2014
Hi Is it possible to easily switch the variable positions in a matirx. For example, I have 4 time series variables, x1, x2, x3 and x4. They form a matrix [x1 x2 x3 x4]. In my program, I want to give an indix that to each of these variables such that if I put 2 1 3 4, the matrix will become [x2 x1 x3 x4]. Many thanks

Risposte (1)

Image Analyst
Image Analyst il 6 Mag 2014
I think you just did it, didn't you? If you want and just have an array x, you can do
new_x = [x(:,2), x(:, 1), x(:, 3), x(:, 4)];

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by