Cody

# Problem 2803. Split up vector or matrix delimited by NaNs

Solution 551047

Submitted on 31 Dec 2014 by rifat
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

### Test Suite

Test Status Code Input and Output
1   Pass
%% x = 7; c_correct = {7}; assert(isequal(split_nan_delimited(x), c_correct ))

2   Pass
%% x = nan; assert(isempty(split_nan_delimited(x)) && iscell(split_nan_delimited(x)))

3   Pass
%% x = [nan; 7; 0; nan]; c_correct = {[7; 0]}; assert(isequal(split_nan_delimited(x), c_correct ))

4   Pass
%% x = rand(66,1); c_correct = {x}; assert(isequal(split_nan_delimited(x), c_correct ))

5   Pass
%% x = (1:20)'; c_correct = {x}; assert(isequal(split_nan_delimited(x), c_correct ))

6   Pass
%% x = [1 76 -inf 0 3 nan 16 7 2 1 0 0 inf 13]'; c_correct = {x(1:5) x(7:end)}; assert(isequal(split_nan_delimited(x), c_correct ))

7   Pass
%% x = (1:34)'; x([6:7 19:21 30]) = nan; c_correct = {x(1:5) x(8:18) x(22:29) x(31:end)}; assert(isequal(split_nan_delimited(x), c_correct ))

8   Pass
%% x = 10*rand(55,6)-5; x([1:2 6 13:15 40],:) = nan; c_correct = {x(3:5,:) x(7:12,:) x(16:39,:) x(41:end,:)}; assert(isequal(split_nan_delimited(x), c_correct ))

9   Pass
%% x = [nan(4); magic(4); nan(1,4); inf(4); ones(4)]; c_correct = {magic(4) [inf(4); ones(4)]}; assert(isequal(split_nan_delimited(x), c_correct ))

10   Pass
%% x = nan(6); c_correct = {}; assert(isequal(split_nan_delimited(x), c_correct ))

11   Pass
%% x = [nan(4); ones(1,4)]; c_correct = {ones(1,4)}; assert(isequal(split_nan_delimited(x), c_correct ))