function [stateEnergy] = calcStateEnergy(profileData, stateName)
    stateTimes = find(profileData.state == stateName);
    startTime = find(profileData.pumpEnergyCalcDT >= profileData.DT(stateTimes(1)));
    endTime = find(profileData.pumpEnergyCalcDT <= profileData.DT(stateTimes(end)));
    stateEnergy = profileData.pumpEnergyCalcSum(endTime(end)) - profileData.pumpEnergyCalcSum(startTime(1));
end