variable positions in matrix

2 次查看(过去 30 天)
Linden
Linden 2014-5-6
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

回答(1 个)

Image Analyst
Image Analyst 2014-5-6
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)];

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by