Manipulate Cell Arrays
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I have a problem regarding cell arrays:
I have an cell array named sets of 10 cells. In each cell I want to store arrays with 2 columns and a variable numer of rows. I don`t know how to add a new row into a special cell. I think it is an indexing problem?
sets=cell(1,10);
sets{1,1}=[sets(1,1) [3,3]];
What is wrong with that? So the problem is: how to concatenate a matrix stored in a cell array cell with a new row?
Thanks for your efforts!
0 commentaires
Réponse acceptée
Plus de réponses (1)
Lucas García
le 29 Août 2011
Let's see if I understand your question. First, you say: " In each cell I want to store arrays with 2 columns and a variable numer of rows".
This array can't be a matrix, since matrices must have all the same number of rows. But each column can be placed in a cell:
x = (1:10)';
y = (1:11)';
sets{1,1} = {x,y};
By using the braces, {x,y} , you are creating a cell of size 1x2 in the first position of the cell sets. If you want now to index into the cell sets and add a row no.12 with value 12 in the position where you placed y, you can do the following:
sets{1,1}{1,2}(12,1) = 12;
This is what you now have in the position 1,1 of cell sets:
>> sets{1,1}
ans =
[10x1 double] [12x1 double]
And this is what you have in second cell contained in the first cell of cell sets:
>> sets{1,1}{1,2}
ans =
1
2
3
4
5
6
7
8
9
10
11
12
0 commentaires
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!