Flip a matrix from 31 x 1000 to 1000 x 31 and retain same order of elements

1 vue (au cours des 30 derniers jours)
Hi!
I have created a 31 x 1000 matrix. The 31 are years from 2020 to 2050, while the 1000 are different simulation outcomes. I will export this to Excel where my years are ordered horizontally, and the outcomes of the simulation vertically. Therefore I need the outcome to be 1000 x 31. How can I flip the matrix so that I achieve this? The elements need to follow each other exactely, because they represent yearly revenues.
Thanks,
Mak

Réponse acceptée

Kevin Holly
Kevin Holly le 12 Oct 2021
You can tranpose the matrix with a '
matrix = rand(3,10)
matrix = 3×10
0.1734 0.4955 0.4469 0.7261 0.6025 0.6068 0.0785 0.0159 0.2856 0.7666 0.3577 0.8180 0.6540 0.2144 0.7027 0.2941 0.3335 0.1094 0.6542 0.1000 0.3746 0.8411 0.4985 0.5843 0.1917 0.4901 0.7395 0.6821 0.2456 0.7785
matrix_transposed = matrix'
matrix_transposed = 10×3
0.1734 0.3577 0.3746 0.4955 0.8180 0.8411 0.4469 0.6540 0.4985 0.7261 0.2144 0.5843 0.6025 0.7027 0.1917 0.6068 0.2941 0.4901 0.0785 0.3335 0.7395 0.0159 0.1094 0.6821 0.2856 0.6542 0.2456 0.7666 0.1000 0.7785

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by