Cody

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

Solution 758662

Submitted on 12 Oct 2015 by Peng Liu
• Size: 7
• This is the leading solution.
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
%% a=100; b=5; c=87; y=change_var(a,10); assert(isequal(a,10));

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.]

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

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.]

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

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.]

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

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.]

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

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.]

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

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.]