Cody

Solution 2014558

Submitted on 11 Nov 2019
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; assert(isequal({1},replace_zeros_and_NaNs(A)))

Error using cell2mat Too many input arguments. Error in replace_zeros_and_NaNs (line 2) C = cell2mat(A,size(A,1),size(A,2)) Error in Test1 (line 2) assert(isequal({1},replace_zeros_and_NaNs(A)))

2   Fail
A = [1 0; NaN 1]; C_correct = {1, 'error'; 'error', 1}; assert(isequal(C_correct, replace_zeros_and_NaNs(A)))

Error using cell2mat Too many input arguments. Error in replace_zeros_and_NaNs (line 2) C = cell2mat(A,size(A,1),size(A,2)) Error in Test2 (line 3) assert(isequal(C_correct, replace_zeros_and_NaNs(A)))

3   Fail
A = []; assert(isequal({}, replace_zeros_and_NaNs(A)))

Error using cell2mat Too many input arguments. Error in replace_zeros_and_NaNs (line 2) C = cell2mat(A,size(A,1),size(A,2)) Error in Test3 (line 2) assert(isequal({}, replace_zeros_and_NaNs(A)))

4   Fail
A = magic(5); A([14 3 5 6 7]) = 0; A([1 18 15 20 22]) = NaN; C_correct = {'error' 'error' 1 8 15; 23 'error' 7 14 'error';'error' 6 13 'error' 22; 10 12 'error' 21 3; 'error' 18 'error' 'error' 9}; assert(isequal(C_correct, replace_zeros_and_NaNs(A)))

Error using cell2mat Too many input arguments. Error in replace_zeros_and_NaNs (line 2) C = cell2mat(A,size(A,1),size(A,2)) Error in Test4 (line 3) assert(isequal(C_correct, replace_zeros_and_NaNs(A)))