This solution is outdated. To rescore this solution, sign in.
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
M=[1 4 7 10;
2 5 8 11;
3 6 9 12];
R=2;C=3;
X(:,:,1) =[1 4 7 ; 2 5 8];
X(:,:,2) =[2 5 8 ; 3 6 9];
X(:,:,3) =[4 7 10 ; 5 8 11];
X(:,:,4) =[5 8 11 ; 6 9 12];
assert(isequal(BreakTheMatrix(M,R,C),X))
|
2 | Pass |
x=1:ceil(35+25*rand());r=1;c=1;
M=BreakTheMatrix(x,r,c);
assert(all(arrayfun(@(y) (M(:,:,y)==y),1:numel(x))))
|
3 | Pass |
x=eye(7);r=2;c=2;
M=BreakTheMatrix(x,r,c);
ids=[1 8 15 22 29 36];
urs=ids(1:5)+1;
lls=urs+5;
z=setxor(1:size(M,3),[ids urs lls]);
a1=arrayfun(@(a) isequal(M(:,:,a),eye(2)),ids);
a2=arrayfun(@(a) isequal(M(:,:,a),[0 1 ; 0 0]),urs);
a3=arrayfun(@(a) isequal(M(:,:,a),[0 0 ; 1 0]),lls);
a4=arrayfun(@(a) isequal(M(:,:,a),zeros(2)),z);
assert(all([a1 a2 a3 a4]))
|
4 | Pass |
u=ceil(10*rand())+4;
x=magic(u);r=u;c=u;
M=BreakTheMatrix(x,r,c);
assert(isequal(M,x))
|
349 Solvers
Vectorize the digits of an Integer
269 Solvers
Set some matrix elements to zero
290 Solvers
521 Solvers
556 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!