Assuming you have time-stamped position vectors (e.g. using read_position function available in the download section for Matlab), use the script shown below to calculate speed using a moving window of a specific width.

Speed vs time

Speed distribution

% SPEED_PROFILE(data, dt, bar_edges)
% Plots speed vs time and a histogram profile of speed within <bar_edges>.
% <data> is a matrix with columns time, x and y.
% <dt> is the bin size to compute speed on a moving window.
%
% Example:
%   data = read_position('VR20151014100000.csv');
%   speed_profile(data);
%   speed_profile(data, 1, 0:1:20);
%
% 2015-08-10. Leonardo Molina.
% 2015-10-15. Last modification.
function v = speed_profile(data, dt, bar_edges)
    % Flag missing inputs.
    if nargin < 3
        bar_edges = [];
    end
    if nargin < 2
        dt = [];
    end

    % Extract t, x, y.
    t = data(:,1);
    x = data(:,2);
    y = data(:,3);
    clear('data');

    % Allocate space for deltas.
    dds = NaN(size(t));
    dts = NaN(size(t));

    % Integration window is 1s by default.
    if isempty(dt)
        dt = 1;
    end

    % If upper limit is missing, integration window can be up to 25% larger.
    if numel(dt) == 1
        dt = [dt dt*1.25];
    end

    % Compute speed in a moving window.
    done = false;
    p1 = 1;
    while ~done
        p2 = find(t(p1 + 1:end) >= t(p1) + dt(1), 1) + p1;
        if isempty(p2)
            done = true;
        else
            dds(p1) = sum(sqrt(diff(x(p1:p2)).^2 + diff(y(p1:p2)).^2));
            dts(p1) = t(p2) - t(p1);
            p1 = p1 + 1;
        end
    end
    v = dds./dts;

    % Permit bin sizes between 1 to 1.25 times dt.
    invalid = isnan(dds) | dts > dt(2);
    v(invalid) = 0;

    % Plot speed vs time.
    figure;
    plot(t, v);
    title('Speed');
    xlabel('Time (s)');
    ylabel('Speed (cm/s)');
    axis('tight');

    % Speed profile.
    if isempty(bar_edges)
        bar_edges = linspace(min(v), max(v), 20);
    end

    % Normalized counts.
    h = histc(v, bar_edges);
    h = h/sum(h);

    % Plot probability distribution.
    figure;
    bar(bar_edges,h,1);
    axis('tight');
    xlabel('Speed (cm/s)');
    ylabel('Probability');

    % Display counts up to second largest.
    if (sum(h > 0) > 1)
        [~,s] = sort(h, 'descend');
        k = s(2);
        ylim([0 h(k)]);
        txt = 'Speed profile.\nProbability(speed[%.2f .. %.2f]) = %.2f';
        title(sprintf(txt, bar_edges(s(1)), bar_edges(s(1)+1), h(s(1))));
    else
        title(sprintf('Speed profile'));
    end
end