Cody

# Problem 2037. Insert structure in a parameter-cell array.

Solution 371292

Submitted on 17 Dec 2013 by Thomas Vanaret
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% x = {'string','blah',struct('position',[10 10 100 20]),'tag','me'}; y = mix2cell(x); y_correct = {'string','blah','position',[10 10 100 20],'tag','me'}; assert(isequal(y,y_correct))

y = 'string' 'blah' 'position' [1x4 double] 'tag' 'me'

2   Pass
%% x = {'string','blahblah','tag','me'}; y = mix2cell(x); y_correct = {'string','blahblah','tag','me'}; assert(isequal(y,y_correct))

y = 'string' 'blahblah' 'tag' 'me'

3   Pass
%% x = {'string','blah',struct('value',rand(100),'backgroundcolor',[1 0 1]),'tag','me too',struct('foregroundcolor',[0 1 0.5])}; y = mix2cell(x); y_correct = {'string','blah','value',x{3}.value,'backgroundcolor',[1 0 1],'tag','me too','foregroundcolor',[0 1 0.5]}; assert(isequal(y,y_correct))

y = Columns 1 through 7 'string' 'blah' 'value' [100x100 double] 'backgroundcolor' [1x3 double] 'tag' Columns 8 through 10 'me too' 'foregroundcolor' [1x3 double]

4   Pass
%% x = {'string','blah',struct('string','blahblah'),'string','',struct('string','this one')}; y = mix2cell(x); y_correct = {'string','blah','string','blahblah','string','','string','this one'}; assert(isequal(y,y_correct))

y = 'string' 'blah' 'string' 'blahblah' 'string' '' 'string' 'this one'