Cody

# Problem 2911. Matlab Basics II - squares

Solution 2894108

Submitted on 31 Aug 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
x = [1 2 3]; y_correct = [1 4 9]; assert(isequal(square_elements(x),y_correct))

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 square_elements (line 2) y = (x^2); Error in Test1 (line 3) assert(isequal(square_elements(x),y_correct))

2   Fail
x = [33 44 5; 56 20 12]; y_correct = [1089 1936 25;3136 400 144]; assert(isequal(square_elements(x),y_correct))

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 square_elements (line 2) y = (x^2); Error in Test2 (line 3) assert(isequal(square_elements(x),y_correct))

3   Fail
x=[3.3 4.4 5; 5.6 2.0 1.2]; y_correct = [10.889999999999999 19.360000000000003 25; 31.359999999999996 4 1.440000000000000]; assert(isequal(square_elements(x),y_correct))

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 square_elements (line 2) y = (x^2); Error in Test3 (line 3) assert(isequal(square_elements(x),y_correct))

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!