How to print out a cell array inside a cell array
14 次查看(过去 30 天)
显示 更早的评论
teampick =
1×4 cell array
{1×4 cell} {1×4 cell} {1×4 cell} {1×4 cell}
0 个评论
采纳的回答
dpb
2019-12-3
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 个评论
dpb
2019-12-4
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!