MATLAB: Concatenation is missing values

concatenationlarge cell structuremissing values

I am using the command:
doubArray = cat(1,cellStruct{:,3});
to extract an array of numeric values from a cell structure of mixed variable types. All of the variables in column 3 of the cell structure are of data type “double“.
The resulting array is missing 33 of the 116397 expected entires. The missing 33 entries are from a variety of locations within the cell structure and there does not appear to be any rhyme or reason behind which entries are missing.
Has anyone encountered this problem before and know of a solution?

Best Answer

33 of the cells in the third column contain empty arrays:
>> find(cellfun('isempty',cellStruct(:,3)))
ans =
21968
21969
27848
35808
43424
52648
52649
52650
52651
52652
52653
52654
52655
60284
60285
60286
60287
60288
60289
60290
60291
60292
60293
60294
60295
60296
60297
60298
60299
65762
65763
65839
65840
While the rest of the cells in the third column apparently have one row:
>> find(cellfun('size',cellStruct(:,3),1)>1)
ans = []
In any case, the total number of rows in all of the cells in the third colum is:
>> sum(cellfun('size',cellStruct(:,3),1))
ans = 116364
And that is the exact number of rows that your numeric array contains:
>> size(doubArray,1)
ans = 116364
So far nothing suggests that any data has gone "missing" when concatenating those cell contents.