Cody

Problem 2669. Assign matrix rows/columns to separate variables

Solution 538983

Submitted on 1 Dec 2014 by J.R.! Menzinger
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 = rand; B = matsplit(A,1); C = matsplit(A,2); assert(isequal(B,A)) assert(isequal(C,A))

2   Pass
%% 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]))

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

4   Pass
%% 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]))

Community Treasure Hunt

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

Start Hunting!