Cody

Problem 2214. Return the names and values of the input arguments of a function

Solution 1711617

Submitted on 21 Jan 2019
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; y=3; assert(isequal(function_io(x,y),' "x" = 1 "y" = 3'))

output = 'x = '

Error using str2num (line 35) Input must be a character vector or string scalar. Error in function_io (line 7) output = [output str2num(t2)] Error in Test1 (line 3) assert(isequal(function_io(x,y),' "x" = 1 "y" = 3'))

2   Fail
x = 100; y= 356; z = 400; assert(isequal(function_io(x,y,z),' "x" = 100 "y" = 356 "z" = 400'))

output = 'x = '

Error using str2num (line 35) Input must be a character vector or string scalar. Error in function_io (line 7) output = [output str2num(t2)] Error in Test2 (line 4) assert(isequal(function_io(x,y,z),' "x" = 100 "y" = 356 "z" = 400'))

3   Fail
x = 0; assert(isequal(function_io(x),' "x" = 0'))

output = 'x = '

Error using str2num (line 35) Input must be a character vector or string scalar. Error in function_io (line 7) output = [output str2num(t2)] Error in Test3 (line 2) assert(isequal(function_io(x),' "x" = 0'))

4   Fail
abc = 0; pqr = 1; xyz = 2; assert(isequal(function_io(abc,pqr,xyz),' "abc" = 0 "pqr" = 1 "xyz" = 2'))

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side. Error in function_io (line 3) t1(m)=inputname(m); Error in Test4 (line 4) assert(isequal(function_io(abc,pqr,xyz),' "abc" = 0 "pqr" = 1 "xyz" = 2'))