Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 294005

Submitted on 1 Aug 2013 by @bmtran

Correct

20Size
Leading solution size is 11.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
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))

                    
2
Pass
 
%%
A = ones(20,1);
C = {'apples','oranges'};
assert(all(strcmp(ind2str(A,C),'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))))

                    
4
Pass
 
%%
A = randi(2,[1,100]);
C = {'0','1'};
assert(isequal(A-1,cellfun(@(c) str2num(c),ind2str(A,C))))

                    
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))