Cody

# Problem 868. Replace all zeros and NaNs in a matrix with the string 'error'

Solution 124716

Submitted on 7 Aug 2012 by Grzegorz Knor
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; assert(isequal({1},replace_zeros_and_NaNs(A)))

``` ans = [1] ans = [1] ```

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

``` ans = [ 1] [0] [NaN] [1] ans = [ 1] 'error' 'error' [ 1] ```

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

``` ans = {} ans = {} ```

4   Pass
%% 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)))

``` ans = [NaN] [ 0] [ 1] [ 8] [ 15] [ 23] [ 0] [ 7] [ 14] [NaN] [ 0] [ 6] [ 13] [NaN] [ 22] [ 10] [12] [ 0] [ 21] [ 3] [ 0] [18] [NaN] [NaN] [ 9] ans = '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] ```