Cody

Problem 2598. What is the scope of variables in Matlab ?

Solution 3241918

Submitted on 16 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
a=100; b=5; c=87; y=change_var(a,10); assert(isequal(a,10));

Unrecognized function or variable 'a'. Error in change_var (line 2) y = a; Error in Test1 (line 4) y=change_var(a,10);

2   Fail
a=[]; b=100; c=9; y=change_var(c,0); assert(isequal(c,0));

Unrecognized function or variable 'a'. Error in change_var (line 2) y = a; Error in Test2 (line 4) y=change_var(c,0);

3   Fail
a=[]; b=100; c=101; d=99; y=change_var(a,0); assert(isequal(a,0));

Unrecognized function or variable 'a'. Error in change_var (line 2) y = a; Error in Test3 (line 5) y=change_var(a,0);

4   Fail
a=[]; c=9; b=100; d=[1 2 3]; y=change_var(b,-8); assert(isequal(b,-8));

Unrecognized function or variable 'a'. Error in change_var (line 2) y = a; Error in Test4 (line 5) y=change_var(b,-8);

5   Fail
a=100; b=5; c=87; y=change_var(c,-8); assert(isequal(c,-8));

Unrecognized function or variable 'a'. Error in change_var (line 2) y = a; Error in Test5 (line 4) y=change_var(c,-8);

6   Fail
a=8; c=9; d=10; b=11; y=change_var(b,c); assert(isequal(b,c));

Unrecognized function or variable 'a'. Error in change_var (line 2) y = a; Error in Test6 (line 5) y=change_var(b,c);

Suggested Problems

More from this Author43

Community Treasure Hunt

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

Start Hunting!