Cody

Solution 2130831

Submitted on 17 Feb 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   Fail
cVec = 5:-.2:-5; ref = (1/sqrt(2*pi*2.5^2))*exp((-1*cVec.^2)/(2*2.5^2)); user = MyFunc(); assert(isequal(user,ref))

cVec = Columns 1 through 18 5.0000 4.8000 4.6000 4.4000 4.2000 4.0000 3.8000 3.6000 3.4000 3.2000 3.0000 2.8000 2.6000 2.4000 2.2000 2.0000 1.8000 1.6000 Columns 19 through 36 1.4000 1.2000 1.0000 0.8000 0.6000 0.4000 0.2000 0 -0.2000 -0.4000 -0.6000 -0.8000 -1.0000 -1.2000 -1.4000 -1.6000 -1.8000 -2.0000 Columns 37 through 51 -2.2000 -2.4000 -2.6000 -2.8000 -3.0000 -3.2000 -3.4000 -3.6000 -3.8000 -4.0000 -4.2000 -4.4000 -4.6000 -4.8000 -5.0000

Error using ^ (line 51) Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in MyFunc (line 3) xVec=sqrt(2*pi*(2.5)^2)\exp(-(cVec)^2/(2*(2.5)^2)) Error in Test1 (line 3) user = MyFunc();

2   Fail
[xVec cVec] = MyFunc(); cRef = 5:-.2:-5; assert(isequal(cRef,cVec))

cVec = Columns 1 through 18 5.0000 4.8000 4.6000 4.4000 4.2000 4.0000 3.8000 3.6000 3.4000 3.2000 3.0000 2.8000 2.6000 2.4000 2.2000 2.0000 1.8000 1.6000 Columns 19 through 36 1.4000 1.2000 1.0000 0.8000 0.6000 0.4000 0.2000 0 -0.2000 -0.4000 -0.6000 -0.8000 -1.0000 -1.2000 -1.4000 -1.6000 -1.8000 -2.0000 Columns 37 through 51 -2.2000 -2.4000 -2.6000 -2.8000 -3.0000 -3.2000 -3.4000 -3.6000 -3.8000 -4.0000 -4.2000 -4.4000 -4.6000 -4.8000 -5.0000

Error using ^ (line 51) Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in MyFunc (line 3) xVec=sqrt(2*pi*(2.5)^2)\exp(-(cVec)^2/(2*(2.5)^2)) Error in Test2 (line 1) [xVec cVec] = MyFunc();

Suggested Problems

More from this Author26