Running a state-updating script twice

Before you run anything, the base workspace holds m = 0.40 (kg), T1 = 18 and T2 = 25 (both in °C). The script heat_step.m is:


MATLAB
c = 4186;          % specific heat of water, J/(kg*K)
dT = T2 - T1;      % temperature rise, K
Q = m*c*dT/1000;   % heat added, kJ
T1 = T2;           % next step starts where this one ended
T2 = T2 + 5;       % next target temperature, deg C


You type heat_step and press Enter, then type heat_step and press Enter a second time. What is the value of Q after the second run? Give your answer in kJ to two decimal places.

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 MATLAB Scripts (M-files) Questions: