How to print out a cell array inside a cell array
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
teampick =
1×4 cell array
{1×4 cell} {1×4 cell} {1×4 cell} {1×4 cell}
0 commentaires
Réponse acceptée
dpb
le 3 Déc 2019
How did you manage to get that so deeply nested? Let's see the code that generated the array and work on it...
But, to answer the question, one just keeps on dereferencing layer after layer...
>> v={{{rand(1,1)},{rand(1,1)}}} % WOW! Why would one do this????
v =
1×1 cell array
{1×2 cell}
>> v{1}{1}
ans =
1×1 cell array
{[0.4720]}
>> v{1}{1}{1}
ans =
0.4720
>>
2 commentaires
dpb
le 4 Déc 2019
Missing the functions being called, but when you start with cell(), then don't use the curlies "{}" for the array addressing but () to avoid inserting the cell into the cell array.
General rule is to only use cell addressing at the lowest level needed to store disparate data types; the cell array itself is just an array.
Alternatively, instead of cell arrays, consider struct with named fields to hold the disparate content of each team...the positions could be the field names.
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!