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:


MATLAB
function E = heaterEnergy(P,t)
    t = t*60;
    E = P*t/1000;
end


The caller executes:


MATLAB
t = 2.5;
energy = heaterEnergy(650,t);


What value is stored in energy? Answer in kJ, to one decimal place.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More User Defined Functions and Function Files Questions: