A test technician saves this function as adjustedLoad.m in MATLAB's current folder. Both inputs and the returned load represent forces in newtons.
function force = adjustedLoad(force, increment) force = force + increment; end
The technician then executes these commands in order in the Command Window:
force = 120; adjustedLoad(force, 15); afterDiscard = force; force = adjustedLoad(force, 25); afterCapture = force;
Complete the table with the final values of afterDiscard and afterCapture. Enter exact integers in newtons. All inputs are ordinary numeric scalars.
Unlock full course notes by signing up
Trace a local unit conversion
A heater transfers energy at a constant rate. The file heaterEnergy.m accepts scalar power P in W and duration t in minutes, and returns transferred energy E in kJ:
The caller executes:
What value is stored in energy? Answer in kJ, to one decimal place.
Pass a dependency through a helper
The function file motorInput.m contains a main function and a local helper function:
Here, Pout and Pin represent power in W, and eta is dimensionless efficiency. In the Command Window, an engineer executes:
The call fails because eta is undefined inside applyEfficiency. There are no global variables or nested functions. Which revision supplies efficiency explicitly through the complete call chain?
Repair a two-output calculation
An engineer saves this code in resistorReport.m to calculate resistor power and energy:
Inputs are scalar current I in A, resistance R in ohms, and duration t in s. The intended outputs are power P in W followed by energy E in J. Assume constant current and resistance.
Compose functions to enforce a power limit
An engineer models a converter supplying a useful electrical load through a resistive cable. These two MATLAB function files are saved in the current folder.
File cableLoss.m:
File supplyPower.m: