Azzera filtri
Azzera filtri

cell2mat:: Cannot support cell arrays containing cell arrays of strings

1 visualizzazione (ultimi 30 giorni)
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. =)

Risposta accettata

Walter Roberson
Walter Roberson il 14 Giu 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 Commenti
Walter Roberson
Walter Roberson il 18 Giu 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);
Diego Tasso
Diego Tasso il 18 Giu 2012
Thanks. I should learn how to use the cellfun function more. I apologize if I gave you a lot of trouble in trying to understand what I was asking but I appreciate any input from you. Thank you.
Diego

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by