Cody

# Problem 1042. Operate on matrices of unequal, yet similar, size

Solution 1996083

Submitted on 30 Oct 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
nocheat = isempty(regexp(evalc('type matched_op'),'([^f]eval|regexprep|inline|str2func)')); x = [1 2;3 4]; y = [1 2]; z_correct = [1 4;3 8]; assert(isequal(matched_op(x,y,'times'),z_correct) && nocheat)

ans = 1 4 3 8

Output argument "z" (and maybe others) not assigned during call to "matched_op". Error in Test1 (line 5) assert(isequal(matched_op(x,y,'times'),z_correct) && nocheat)

2   Fail
nocheat = isempty(regexp(evalc('type matched_op'),'([^f]eval|regexprep|inline|str2func)')); x = [10i]; y = [20]; z_correct = [-2i]; assert(isequal(matched_op(x,y,'ldivide'),z_correct) && nocheat)

ans = 0.0000 - 2.0000i

Output argument "z" (and maybe others) not assigned during call to "matched_op". Error in Test2 (line 5) assert(isequal(matched_op(x,y,'ldivide'),z_correct) && nocheat)

3   Fail
nocheat = isempty(regexp(evalc('type matched_op'),'([^f]eval|regexprep|inline|str2func)')); x = reshape(1:4,[1 1 1 4]); y = (1:4).'; z_correct = reshape([2 3 4 5 3 4 5 6 4 5 6 7 5 6 7 8],[4 1 1 4]); assert(isequal(matched_op(x,y,'plus'),z_correct) && nocheat)

ans(:,:,1,1) = 2 3 4 5 ans(:,:,1,2) = 3 4 5 6 ans(:,:,1,3) = 4 5 6 7 ans(:,:,1,4) = 5 6 7 8

Output argument "z" (and maybe others) not assigned during call to "matched_op". Error in Test3 (line 5) assert(isequal(matched_op(x,y,'plus'),z_correct) && nocheat)