function pos = simulateBlock(time,posInit)

% Find the number of elements in time 
lengthTime = length(time);

% Initialise the vector pos
pos = zeros(lengthTime,1); 

% Position at time(1)
pos(1) = posInit;

% Iteration to find the other positions 
for ii = 2:lengthTime
    pos(ii) = pos(ii-1) + (time(ii)-time(ii-1)) * velocity(time(ii-1));
end   

% For Question C1(b), the above for-loop can be replaced by 
% pos(2:end) = posInit + cumsum(velocity(time(1:end-1)).*(time(2:end)-time(1:end-1))); 