How to print out a cell array inside a cell array
1 view (last 30 days)
Show older comments
teampick =
1×4 cell array
{1×4 cell} {1×4 cell} {1×4 cell} {1×4 cell}
0 Comments
Accepted Answer
dpb
on 3 Dec 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 Comments
dpb
on 4 Dec 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.
More Answers (0)
See Also
Categories
Find more on Data Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!