Save matrices (present within a cell) into a single matrix

1 vue (au cours des 30 derniers jours)
Alberto Acri
Alberto Acri le 5 Jan 2023
Commenté : Stephen23 le 10 Jan 2023
Hi. I would like to save matrices (present within a cell) into one single matrix. How can I do this?
Here is an example of a cell:
C = {rand(1225,3), rand(844,3), rand(1004,3), rand(252,3), rand(779,3)};
I would like to get the result below ("matrix") but without manually creating all the matrices (C1, C2, C3, C4, C5) present inside the cell.
C = {rand(1225,3), rand(844,3), rand(1004,3), rand(252,3), rand(779,3)};
C1 = C{1,1};
C2 = C{1,2};
C3 = C{1,3};
C4 = C{1,4};
C5 = C{1,5};
matrix = [C1; C2; C3; C4; C5];

Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 5 Jan 2023
C={rand(2,3), rand(4,3),rand(5,3)};
D=cell2mat(C')
D = 11×3
0.7979 0.1673 0.1573 0.0727 0.8890 0.5308 0.9318 0.8525 0.1702 0.7646 0.5018 0.3824 0.1174 0.5170 0.2963 0.9404 0.4847 0.2988 0.9093 0.2932 0.2371 0.7827 0.5784 0.8486 0.0534 0.1470 0.1571 0.5680 0.5896 0.9516

Plus de réponses (0)

Catégories

En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by