146k views
5 votes
Part A: Write a function that meets the following expectations: Function name: func_Skill Inputs: d z h Outputs: f x y Operations to be coded within the function: f = (8 * z) - h; x = d / 9; y = f * x; p = f / x - y; Display p to the Command Window with 2 decimal places Use the m-file template provided in the assignment files. Part B Clear all variables out of your workspace. Then, enter the following command into Command Window. >> [out1,out2,out3] = func_Skill(37,35,23) Are any of the inputs defined in the Workspace? Why or why not? Part C Clear all variables out of your workspace. Then, enter the following commands into Command Window. >> in1 = 14; >> in2 = 23; >> in3 = 64; >> [out1,out3] = func_Skill(in1,in2,in3) C.1: Is the second output argument value available in the workspace? Why or why not? C.2: Is the variable 'p' visible in the Workspace? Why or why not? Part D Rewrite the function definition line so that no output arguments are shared to the Workspace.

1 Answer

1 vote

Part A:

scss

Copy code

function [p] = func_Skill(d, z, h)

f = (8 * z) - h;

x = d / 9;

y = f * x;

p = f / x - y;

fprintf('%.2f\\', p);

end

Part B:

No, none of the inputs are defined in the workspace because they are passed as arguments to the function when it is called.

Part C:

C.1: No, the second output argument value is not available in the workspace because it was not assigned to a variable in the command that called the function.

C.2: No, the variable 'p' is not visible in the workspace because it is defined within the function and is not returned or assigned to a variable.

Part D:

scss

Copy code

function func_Skill(d, z, h)

f = (8 * z) - h;

x = d / 9;

y = f * x;

p = f / x - y;

fprintf('%.2f\\', p);

end

In this modified version, the function no longer returns an output argument, and the value of p is only displayed to the Command Window using fprintf.

User JIT Solution
by
7.2k points