Problem 2850. Matlab Basics - Switching Assignments

Solution 1088416

Submitted on 23 Dec 2016
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
[x,y] = swap_vars(5,10); assert(isequal(x,10)); assert(isequal(y,5));

2   Fail
[x,y] = swap_vars('hello','bye'); assert(isequal(x,'bye')); assert(isequal(y,'hello'));

Matrix dimensions must agree. Error in swap_vars (line 2) x = x+y; Error in TestPoint2 (line 1) [x,y] = swap_vars('hello','bye');

3   Fail
[x,y] = swap_vars(5,'hello'); assert(isequal(x,'hello')); assert(isequal(y,5));

Assertion failed.

Suggested Problems

More from this Author28

Community Treasure Hunt

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

Start Hunting!