Cody

# Problem 2953. Split array into pieces according to corresponding array

Solution 2447547

Submitted on 1 Jun 2020
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
x=[ 1 1 1 2 2 3 3 3 3]; y=[10 52 12 58 21 43 89 27 98]; c={[10 52 12],[58 21],[43 89 27 98]}; assert(isequal(split_array(x,y),c))

ans = 10 52 12 ans = 58 21 ans = 43 89 27 98

Output argument "c" (and maybe others) not assigned during call to "split_array". Error in Test1 (line 4) assert(isequal(split_array(x,y),c))

2   Fail
x=1:5; c=num2cell(1:5); assert(isequal(split_array(x,x),c));

ans = 1 ans = 2 ans = 3 ans = 4 ans = 5

Output argument "c" (and maybe others) not assigned during call to "split_array". Error in Test2 (line 3) assert(isequal(split_array(x,x),c));

3   Fail
x=[1 1 1 1 1 2 3 3 3 3 3]; y='Hello world'; c={'Hello' ' ' 'world'} assert(isequal(split_array(x,y),c));

c = 1×3 cell array {'Hello'} {' '} {'world'} ans = 'Hello' ans = ' ' ans = 'world'

Output argument "c" (and maybe others) not assigned during call to "split_array". Error in Test3 (line 4) assert(isequal(split_array(x,y),c));

### Community Treasure Hunt

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

Start Hunting!