Effacer les filtres
Effacer les filtres

Concatenate cell data in an array

1 vue (au cours des 30 derniers jours)
Pieter
Pieter le 19 Avr 2013
Good day,
I have got a cell which looks something like:
c{1} = [2 3
1 3
9 1
9 8
. .
. .]
c{2} = [1 2
3 1
. .
. .]
and so on.
Now I would like to vertically concatenate all data in one array.
The code I am using is:
total = []
for i = 1:size(c,2)
total = [total; c{i}];
end
This works fine, however Matlab suggests preallocation for speed. However, I don't know how to do that in this example.
Thank you in advance.

Réponse acceptée

Matt J
Matt J le 19 Avr 2013
Just do
total=vertcat(c{:})
  1 commentaire
Pieter
Pieter le 19 Avr 2013
Great, thanks a lot!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by