% Sprint Prediction Program with Athlete Input, Scaling, and Graphing (Time and Speed)
% Predicts times for distances from 30m to 150m based on athlete's input and plots the results

% Define the known data points and ranges (from the provided table) from DICK, F. (1987) Sprints and Relays. 5th ed. London: BAAB.
known_distances = [30, 60, 150];  % Known distances

data_30m = [3.58, 3.61; 3.62, 3.65; 3.66, 3.69; 3.70, 3.73; 3.74, 3.77;
            3.78, 3.81; 3.82, 3.85; 3.86, 3.89; 3.90, 3.93; 3.94, 3.98;
            3.99, 4.03; 4.04, 4.08; 4.09, 4.13; 4.14, 4.18; 4.19, 4.24;
            4.25, 4.30; 4.31, 4.36; 4.37, 4.42; 4.43, 4.48; 4.49, 4.54;
            4.55, 4.60; 4.61, 4.70; 4.71, 4.80; 4.81, 4.90; 4.91, 5.00];

data_60m = [6.22, 6.27; 6.28, 6.33; 6.34, 6.39; 6.40, 6.45; 6.46, 6.51;
            6.52, 6.57; 6.58, 6.63; 6.64, 6.69; 6.70, 6.75; 6.76, 6.81;
            6.82, 6.87; 6.88, 6.93; 6.94, 6.99; 7.00, 7.05; 7.06, 7.12;
            7.13, 7.19; 7.20, 7.26; 7.27, 7.33; 7.34, 7.40; 7.41, 7.50;
            7.51, 7.60; 7.61, 7.70; 7.71, 7.80; 7.81, 7.90; 7.91, 8.00];

data_150m = [14.87, 14.97; 14.98, 15.08; 15.09, 15.19; 15.20, 15.30; 15.31, 15.42;
             15.43, 15.54; 15.55, 15.66; 15.67, 15.79; 15.80, 15.92; 15.93, 16.06;
             16.07, 16.20; 16.21, 16.35; 16.36, 16.51; 16.52, 16.68; 16.69, 16.86;
             16.87, 17.05; 17.06, 17.25; 17.26, 17.46; 17.47, 17.67; 17.68, 17.88;
             17.89, 18.09; 18.10, 18.30; 18.31, 18.55; 18.56, 18.81; 18.82, 19.12];

% Define distances to predict
predict_distances = 30:10:150;

% Calculate average times for the known distances
avg_times_30m = mean(data_30m, 2);
avg_times_60m = mean(data_60m, 2);
avg_times_150m = mean(data_150m, 2);

% Organize data for interpolation
all_known_times = [avg_times_30m, avg_times_60m, avg_times_150m];

% Get athlete's input
input_distance = input('Enter the distance you ran (e.g., 50): ');
input_time = input('Enter your time for that distance: ');

% Interpolate the expected time for the input distance based on known data
expected_time = interp1(known_distances, all_known_times', input_distance, 'linear')';

% Calculate the scaling factor based on the athlete's time
scaling_factor = input_time / mean(expected_time);

% Initialize arrays to store predicted times and calculated speeds
predicted_times = zeros(size(predict_distances));
speeds_kmh = zeros(size(predict_distances)); % Speeds in km/h

% Calculate predicted times and speeds for the specified distances
fprintf('\nPredicted Times and Speeds for Distances 30m to 150m:\n');
for i = 1:length(predict_distances)
    distance = predict_distances(i);
    
    % Interpolate the expected time for each distance
    predicted_time = interp1(known_distances, all_known_times', distance, 'linear')';
    
    % Adjust the predicted time by the scaling factor
    adjusted_time = predicted_time * scaling_factor;
    predicted_times(i) = mean(adjusted_time);
    
    % Calculate the speed in m/s and convert to km/h
    speeds_kmh(i) = (distance / predicted_times(i)) * 3.6;
    
    % Display the result
    fprintf('%dm: %.2f seconds, %.2f km/h\n', distance, predicted_times(i), speeds_kmh(i));
end

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: