Create a Cell Array of Vectors populated with ones
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Leonardo Venturelli
le 15 Mai 2019
Modifié(e) : Leonardo Venturelli
le 23 Mai 2019
Hi all,
I 'd like to create a cell array made of x columns and y rows (in my case 10 and 3, respectively), where each x,y position contains a vector of 1x200 NaN. I'd like to find something smarter and nicer than just something like this:
res={nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200) ;nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200); nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200) nan(1,200)};
Thank you so much to the community.
Leonardo
1 commentaire
Guillaume
le 15 Mai 2019
If all the vectors in the cell array are the same size, why not use a matrix instead of a cell array. It will make all subsequent operations much easier.
I.e. create a 10x3x200 matrix instead:
res = nan(10, 3, 200);
Réponse acceptée
Jos (10584)
le 15 Mai 2019
repmat also works for cell arrays
C = repmat({nan(1, 200)}, 10, 3)
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays 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!