cell2mat:: Cannot support cell arrays containing cell arrays of strings
2 views (last 30 days)
Show older comments
Hi!
So I have three cell class variables size of 101x5; each variable apparently contains cell arrays of strings. I need to combine the three of them to form only one cell array of size 101X5. My ultimate goal is to sum them together however I get an error statement:
Undefined function 'sum' for input arguments of type 'cell'
To fix this ( as suggested by Mr. Walter Roberson; thank you by the way ) I need to use the cell2mat function to avoid the error above. So I did that. Now I get the following error:
Cannot support cell arrays containing cell arrays or objects.
Anyone have any ideas how I may reach my ultimate goal? or how I can fix the cell2mat error?
Either way any help is appreciate it. =)
0 Comments
Accepted Answer
Walter Roberson
on 14 Jun 2012
Suppose V1 = {'A'}, V2 = {'B'}, V3 = {'C'} -- the 1x1 simplification of your problem. Now what would it mean for you to "sum" these cell arrays? Would you be trying to get the result 'ABC'? Or would you be trying to get the result char('A' + 'B' + 'C')?
Or would you be wanting the variable named 'A' to be looked up and its numeric value extracted, and the variable named 'B' to be looked up and its numeric value extracted, and likewise for the variable named 'C', and then to sum those three numeric values. If the cell array contains the names of variables whose sum should be taken, then Don't Do That!
5 Comments
Walter Roberson
on 18 Jun 2012
T = ~cellfun(@isempty, Sheet1);
FinalSheet(T) = Sheet1(T);
T = ~cellfun(@isempty, Sheet2);
FinalSheet(T) = Sheet2(T);
T = ~cellfun(@isempty, Sheet3);
FinalSheet(T) = Sheet3(T);
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!