Solution 2096059

Submitted on 17 Jan 2020
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
filetext = fileread('outerProduct.m'); assert(~contains(filetext,'regexp'))

2   Fail
y = outerProduct([],[]); assert(isempty(y))

Assertion failed.

3   Pass
x = randi(100); y = randi(100); assert(isequal(outerProduct(x,y),x*y))

4   Fail
x = randi(100,[1 100]); y = randi(100,[1 90]); assert(isequal(outerProduct(x,y),x.'*y)) assert(isequal(outerProduct(x.',y),x.'*y)) assert(isequal(outerProduct(x,y.'),x.'*y))

Error using * Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'. Error in outerProduct (line 4) z = x.' * y; Error in Test4 (line 3) assert(isequal(outerProduct(x,y),x.'*y))

5   Fail
x = randi(100,[1 1000]); xc = num2cell(x); assert(isequal(outerProduct(xc{:}),prod(x)))

Error using outerProduct Too many input arguments. Error in Test5 (line 3) assert(isequal(outerProduct(xc{:}),prod(x)))