Cody

Solution 1190763

Submitted on 16 May 2017
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   Fail
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))

Assertion failed.

2   Fail
A = ones(20,1); C = {'apples','oranges'}; assert(all(strcmp(ind2str(A,C),'apples')))

Assertion failed.

3   Fail
A = randi(1000,[22,10]); C = arrayfun(@(x) num2str(x),1:1000,'uni',0); assert(isequal(A,cellfun(@(c) str2num(c),ind2str(A,C))))

Error using str2num (line 31) Requires character vector or array input. Error in TestPoint3>@(c)str2num(c) Error in TestPoint3 (line 3) assert(isequal(A,cellfun(@(c) str2num(c),ind2str(A,C))))

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

Error using str2num (line 31) Requires character vector or array input. Error in TestPoint4>@(c)str2num(c) Error in TestPoint4 (line 3) assert(isequal(A-1,cellfun(@(c) str2num(c),ind2str(A,C))))

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

Assertion failed.