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:
function loss = cableLoss(current, resistance) loss = current^2 * resistance; end
File supplyPower.m:
function inputPower = supplyPower(outputPower, efficiency) inputPower = outputPower / efficiency; end
The useful load is 480 W, the cable current is 12 A and the converter efficiency is 0.80. The engineer types this composed call at the Command Window:
P = supplyPower(480 + cableLoss(12, 0.35), 0.80)
Find the value MATLAB stores in P, in watts to one decimal place. Then the engineer replaces the resistance argument with a variable R, so the call becomes supplyPower(480 + cableLoss(12, R), 0.80). Find the value of R for which this call returns exactly 690, in ohms to three decimal places.
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.
Discard or capture a returned load
A test technician saves this function as adjustedLoad.m in MATLAB's current folder. Both inputs and the returned load represent forces in newtons.
The technician then executes these commands in order in the Command Window:
Complete the table with the final values of afterDiscard and afterCapture. Enter exact integers in newtons. All inputs are ordinary numeric scalars.
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.