MATLAB: I need reset the ‘New Time’ so that it starts at 0 when ‘New Velocity’ = anything other then 0

plotting

i=1;
while(yAngVel(i)==0)
i=i+1;
end
NewVelocity=yAngVel(i:end);
NewTime=xTime(i:end);
figure
plot(NewTime,NewVelocity,'r-')

Best Answer

index = find(yAngVel, 1);
NewVelocity = yAngVel(index:end);
NewTime = xTime(index:end) - xTime(index);