I manage to do a 10 fold and store the data into a cell and my cell has the following structure:
[135x5 double] [15x5 double]
[135x5 double] [15x5 double]
[135x5 double] [15x5 double]
[135x5 double] [15x5 double]
[135x5 double] [15x5 double]
[135x5 double] [15x5 double]
[135x5 double] [15x5 double]
[135x5 double] [15x5 double]
[135x5 double] [15x5 double]
[135x5 double] [15x5 double]
here is a small snapshot of what data is in this cell, let say we assign this cell in to a variable cell here is the cell{1,1} – This is actually Iris data
5.1000 3.3000 1.7000 0.5000 1.0000
6.8000 3.2000 5.9000 2.3000 3.0000
5.0000 2.3000 3.3000 1.0000 2.0000
7.4000 2.8000 6.1000 1.9000 3.0000
6.5000 3.2000 5.1000 2.0000 3.0000
4.8000 3.4000 1.9000 0.2000 1.0000
cell{1,2}
7.2000 3.2000 6.0000 1.8000 3.0000
6.1000 2.6000 5.6000 1.4000 3.0000
6.4000 2.9000 4.3000 1.3000 2.0000
6.8000 3.0000 5.5000 2.1000 3.0000
6.1000 2.8000 4.0000 1.3000 2.0000
Now I am trying to iterate over each of the row and anyalze the data in first column Cell{1,1}, Cell{1,2)… How can I do that? What is the technique to iterate over cell?
Does this cut-down example solve your problem?
I use
cell2matto concatenate all the matrices in the first column of your cell array into one big matrix, and then the last line just grabs the first column of that matrix.If you were instead asking how to loop over a cell array, well, you do it the same way as over a numeric array, but using curly braces to index the elements of the cell array ie:
Or you could combine those two lines into:
FirstColumnOfCurrentCell = Z{i, 1}(:, 1);A final point, don’t use
cellas the name of a variable. This is not good practice, sincecellis also the name of an in-built matlab function