Cody

Problem 2669. Assign matrix rows/columns to separate variables

Solution 2000557

Submitted on 3 Nov 2019
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
A = rand; B = matsplit(A,1); C = matsplit(A,2); assert(isequal(B,A)) assert(isequal(C,A))

Output argument "varargout{1}" (and maybe others) not assigned during call to "matsplit". Error in Test1 (line 2) B = matsplit(A,1);

2   Fail
rng default A = randi(100,3,3); [B,C,D] = matsplit(A,1); [E,F,G] = matsplit(A,2); assert(isequal(B,[82;91;13])) assert(isequal(C,[92;64;10])) assert(isequal(D,[28;55;96])) assert(isequal(E,[82,92,28])) assert(isequal(F,[91,64,55])) assert(isequal(G,[13,10,96]))

Output argument "varargout{1}" (and maybe others) not assigned during call to "matsplit". Error in Test2 (line 3) [B,C,D] = matsplit(A,1);

3   Fail
A = hankel(1:20); B = matsplit(A,1); C = matsplit(A,2); assert(isequal(C,1:20)) assert(isequal(B(:),C(:)))

Output argument "varargout{1}" (and maybe others) not assigned during call to "matsplit". Error in Test3 (line 2) B = matsplit(A,1);

4   Fail
A = toeplitz(1:4); [B,C,D,E] = matsplit(A,2); assert(isequal(B,[1 2 3 4])) assert(isequal(C,[2 1 2 3])) assert(isequal(D,[3 2 1 2])) assert(isequal(E,[4 3 2 1]))

Output argument "varargout{1}" (and maybe others) not assigned during call to "matsplit". Error in Test4 (line 2) [B,C,D,E] = matsplit(A,2);