Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 237543

Submitted on 29 Apr 2013

Incorrect

15Size
Leading solution size is 17.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
A = magic(3);
mask = logical([0 1 1; 0 1 1; 0 1 1]);
y_correct = [1 6; 5 7; 9 2];
assert(isequal(logicalBlock(A,mask),y_correct))

                    
2
Pass
 
%%
A = magic(4);
mask = logical([0 0 0 0; 0 1 1 0; 0 1 1 0; 0 0 0 0]);
y_correct = [11 10; 7 6];
assert(isequal(logicalBlock(A,mask),y_correct))

                    
3
Fail
 
%%
A = magic(4);
mask = logical([1 1 1 0; 1 1 1 0; 0 0 0 0; 0 0 0 0]);
y_correct = [16 2 3; 5 11 10];
assert(isequal(logicalBlock(A,mask),y_correct))
Error: Assertion failed.
4
Fail
 
%%
A = magic(5);
mask = logical(ones(5));
y_correct = magic(5);
assert(isequal(logicalBlock(A,mask),y_correct))
Error: Product of known dimensions, 2, not divisible into total number of elements, 25.