Cody

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

Solution 120221

Submitted on 30 Jul 2012 by Andrei Bobrov
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]

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

ans = [ 1] 'error' 'error' [ 1]

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

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 = '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]

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!