Function Calls Given the following functions test 1 and test
Solution
Please follow the data and description :
CODE :
function res = test1(x,y)
 res = sqrt(x.^2+y.^2);
 end
 function res = test2(x,y)
 narginchk(1,2)
   
 if nargin == 2
 res = sqrt(x.^2+y.^2);
 else
 res = x;
 end
 end
a) out = test1();
In this case the code rises a error as the sufficient variables are not passed to the function ofr the code to run the output. The error raises that the variable x could not be defined or undefined.
b) out = test1(6);
For the above line of code even the it rises a error as the sufficient variables are not passed to the function ofr the code to run the output. The error raises that the variable y could not be defined or undefined.
c) out = test1(3,4); :
For this the code gives the output for the variables that get the output desired. The value generated would be 5 as root of squares of the values passed is 5.
d) out = test2(12); :
This gives the value passed as the output as the condition that needs to be checked is not satisfied and thus the code goes to the else condition which outputs the value that is passed, which results the output as 12.
e) out = test2(6,8); :
This prints the value 10 as the output as the values are satisfied for the given condition and thus results the sqrt of the values which is 10.
f) out = test2(8,10,12); :
This generates the error as the arguments that need to be passed are two and the passed values are 3 so results in an error as the too many arguments for the given function call.
 Hope this is helpful.

