Cody

# Problem 688. Convert a structure into a string

Solution 1631557

Submitted on 21 Sep 2018 by Michael Jarboe
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
s.age = '33' s.prenom ='aurélien' str_correct = ['33',10,'aurélien']; assert(isequal(your_fcn_name(s),str_correct))

s = struct with fields: age: '33' s = struct with fields: age: '33' prenom: 'aurélien' x = 2×1 cell array {'age' } {'prenom'} str = [] z = '33' str = '33' z = 'aurélien' str = '33 aurélien'

2   Pass
s.f1 = 'Sunday'; s.f2 = 'Monday'; s.f3 = 'Tuesday'; s.f4 = 'Wednesday'; s.f5 = 'Thursday'; s.f6 = 'Friday'; s.f7 = 'Saturday'; str_correct = ['Sunday',10,'Monday',10,'Tuesday',10,'Wednesday',10,'Thursday',10,'Friday',10,'Saturday']; assert(isequal(your_fcn_name(s),str_correct))

x = 7×1 cell array {'f1'} {'f2'} {'f3'} {'f4'} {'f5'} {'f6'} {'f7'} str = [] z = 'Sunday' str = 'Sunday' z = 'Monday' str = 'Sunday Monday' z = 'Tuesday' str = 'Sunday Monday Tuesday' z = 'Wednesday' str = 'Sunday Monday Tuesday Wednesday' z = 'Thursday' str = 'Sunday Monday Tuesday Wednesday Thursday' z = 'Friday' str = 'Sunday Monday Tuesday Wednesday Thursday Friday' z = 'Saturday' str = 'Sunday Monday Tuesday Wednesday Thursday Friday Saturday'

3   Pass
s.age = '42'; s.height = '73.5'; s.weight = '173'; str_correct = ['42',10,'73.5',10,'173']; assert(isequal(your_fcn_name(s),str_correct))

x = 3×1 cell array {'age' } {'height'} {'weight'} str = [] z = '42' str = '42' z = '73.5' str = '42 73.5' z = '173' str = '42 73.5 173'

4   Pass
s.hair = 'brown'; s.eye = 'green'; s.fav = 'gold'; str_correct = ['brown',10,'green',10,'gold']; assert(isequal(your_fcn_name(s),str_correct))

x = 3×1 cell array {'hair'} {'eye' } {'fav' } str = [] z = 'brown' str = 'brown' z = 'green' str = 'brown green' z = 'gold' str = 'brown green gold'

5   Pass
s.first = 'Tom'; s.second = 'Jeff'; s.third = 'Bill'; s.fourth = 'Jerry'; s.fifth = 'Harold'; str_correct = ['Tom',10,'Jeff',10,'Bill',10,'Jerry',10,'Harold']; assert(isequal(your_fcn_name(s),str_correct))

x = 5×1 cell array {'first' } {'second'} {'third' } {'fourth'} {'fifth' } str = [] z = 'Tom' str = 'Tom' z = 'Jeff' str = 'Tom Jeff' z = 'Bill' str = 'Tom Jeff Bill' z = 'Jerry' str = 'Tom Jeff Bill Jerry' z = 'Harold' str = 'Tom Jeff Bill Jerry Harold'