Cody

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

Solution 552869

Submitted on 6 Jan 2015 by Alfonso Nieto-Castanon
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
%% 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(isempty(split_nan_delimited(x)) && iscell(split_nan_delimited(x)))

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

### Community Treasure Hunt

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

Start Hunting!