I have some vectors of data for time, vehicle fuel consumption, and vehicle speed for a certain driving trip. I am confused about how to tell Matlab to sum up the fuel used for all time when vehicle speed=0...any help with this would be sincerely and greatly appreciated! Here is what I have right now:
[ZeroSpeed, IdleFuelIndex] = min(VSPD);
IdleFuelTime = time(IdleFuelIndex);
IdleFuel=0;
for n=1:length(time)-1
IdleFuel(n+1) = Fuel_Consumed(IdleFuelTime)(n+1) + IdleFuel(n);
end
min(VSPD)=0, so IdleFuelTime should return the times when VSPD=0. (VSPD is the variable for vehicle speed). The problem is, Matlab is only returning for the first time that vehicle speed is zero! Also, I'm not sure about the for loop...perhaps I'm on the right track though? IdleFuel (the fuel consumed while the vehihcle is idling) is supposed to be equal to the summation of the fuel consumed by the vehicle at IdleFuelTime (whenever VSPD=0).
Thank you so much for your help with this, in advance! I'm really stuck on this.