Cody

# Problem 2769. Find out magnitude of vector

Solution 3451438

Submitted on 28 Oct 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 = 3.7417; assert(abs(vector_mag(x)-y_correct)<0.0001)

Error using assert The condition input argument must be convertible to a scalar logical. Error in Test1 (line 3) assert(abs(vector_mag(x)-y_correct)<0.0001)

2   Fail
x = [-1 5 -6]; y_correct = 7.8740; assert(abs(vector_mag(x)-y_correct)<0.0001)

Error using assert The condition input argument must be convertible to a scalar logical. Error in Test2 (line 3) assert(abs(vector_mag(x)-y_correct)<0.0001)

3   Fail
x = [3 4 5]; y_correct = 7.0711; assert(abs(vector_mag(x)-y_correct)<0.0001)

Error using assert The condition input argument must be convertible to a scalar logical. Error in Test3 (line 3) assert(abs(vector_mag(x)-y_correct)<0.0001)

4   Fail
x = [5 5 -5]; y_correct = 8.6603; assert(abs(vector_mag(x)-y_correct)<0.0001)

Error using assert The condition input argument must be convertible to a scalar logical. Error in Test4 (line 3) assert(abs(vector_mag(x)-y_correct)<0.0001)

5   Pass
isempty(regexp(evalc('type vector_mag'),'sum'))

ans = logical 1

### Community Treasure Hunt

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

Start Hunting!