Assigning a cell array to a cell of a different cell array
Show older comments
I need to assign a cell array to an element of a different cell array. ie:
child = {'a', 'b', 'c'};
parent = cell(2,1);
parent{1} =child;
This code works when child contains more than one element. However when child contains only one element, the element value is copied rather than a 1x1 cell array. ie:
child = {'a'};
parent = cell(2,1);
parent{1} = child;
In this case printing parent shows that the first element of parent is a string, 'a', rather than a 1x1 cell array. How can I override this behavior?
Accepted Answer
More Answers (0)
Categories
Find more on Numeric Types 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!