Cody

Solution 287901

Submitted on 23 Jul 2013 by James
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
%% A = [1 2 3 2 3 1 3 1 2]; C = {'yes','no','maybe'}; B_correct = {'yes' 'no' 'maybe' 'no' 'maybe' 'yes' 'maybe' 'yes' 'no'}; assert(isequal(ind2str(A,C),B_correct))
ans = 'yes' 'no' 'maybe' 'no' 'maybe' 'yes' 'maybe' 'yes' 'no'
2   Pass
%% A = ones(20,1); C = {'apples','oranges'}; assert(all(strcmp(ind2str(A,C),'apples')))
ans = Columns 1 through 8 'apples' 'apples' 'apples' 'apples' 'apples' 'apples' 'apples' 'apples' Columns 9 through 16 'apples' 'apples' 'apples' 'apples' 'apples' 'apples' 'apples' 'apples' Columns 17 through 20 'apples' 'apples' 'apples' 'apples'
3   Pass
%% A = randi(1000,[22,10]); C = arrayfun(@(x) num2str(x),1:1000,'uni',0); assert(isequal(A,cellfun(@(c) str2num(c),ind2str(A,C))))
ans = '661' '457' '146' '848' '727' '268' '457' '927' '696' '269' '606' '450' '365' '668' '607' '594' '416' '174' '97' '804' '528' '661' '807' '648' '687' '849' '218' '374' '579' '198' '499' '986' '815' '810' '660' '967' '998' '433' '327' '324' '339' '22' '563' '578' '783' '102' '355' '14' '350' '739' '626' '50' '585' '550' '159' '664' '910' '577' '64' '69' '806' '686' '348' '280' '350' '657' '419' '987' '10' '407' '137' '144' '497' '542' '622' '140' '694' '908' '928' '427' '459' '229' '570' '154' '910' '222' '475' '676' '552' '523' '696' '395' '458' '781' '984' '293' '965' '774' '405' '341' '718' '602' '365' '451' '161' '70' '116' '978' '781' '128' '618' '468' '637' '275' '102' '152' '980' '630' '444' '891' '772' '401' '434' '100' '493' '663' '590' '206' '48' '234' '950' '921' '844' '256' '356' '931' '679' '71' '617' '53' '587' '63' '395' '906' '843' '123' '73' '511' '629' '540' '607' '126' '731' '54' '759' '35' '366' '789' '6' '85' '654' '887' '675' '244' '956' '774' '564' '765' '143' '366' '92' '299' '9' '974' '63' '868' '568' '950' '663' '432' '315' '969' '531' '359' '916' '576' '341' '966' '921' '483' '698' '148' '385' '186' '596' '212' '328' '756' '972' '512' '125' '154' '509' '453' '382' '476' '625' '364' '964' '292' '12' '661' '210' '409' '803' '969' '735' '792' '354' '432'
4   Pass
%% A = randi(2,[1,100]); C = {'0','1'}; assert(isequal(A-1,cellfun(@(c) str2num(c),ind2str(A,C))))
ans = Columns 1 through 14 '0' '0' '1' '1' '1' '0' '0' '1' '0' '1' '0' '0' '0' '1' Columns 15 through 28 '1' '0' '1' '0' '1' '1' '0' '1' '1' '1' '1' '1' '0' '0' Columns 29 through 42 '1' '1' '1' '1' '1' '1' '0' '0' '1' '1' '1' '0' '1' '1' Columns 43 through 56 '1' '0' '0' '0' '1' '0' '0' '1' '0' '0' '1' '1' '1' '0' Columns 57 through 70 '1' '1' '1' '0' '1' '1' '0' '1' '0' '1' '0' '1' '1' '1' Columns 71 through 84 '0' '1' '0' '0' '1' '0' '1' '0' '1' '1' '1' '0' '0' '0' Columns 85 through 98 '0' '0' '0' '1' '0' '0' '1' '0' '1' '0' '0' '0' '1' '1' Columns 99 through 100 '0' '0'
5   Pass
%% A = [2 4 4 2 2 4]; C = {'foo','bar','baz','qux'}; B_correct = {'bar' 'qux' 'qux' 'bar' 'bar' 'qux'}; assert(isequal(ind2str(A,C),B_correct))
ans = 'bar' 'qux' 'qux' 'bar' 'bar' 'qux'