Skip to content

Instantly share code, notes, and snippets.

@sunsided
Created July 16, 2022 11:01
Show Gist options
  • Save sunsided/f5628292ac17ba68df8da7b58c2a0766 to your computer and use it in GitHub Desktop.
Save sunsided/f5628292ac17ba68df8da7b58c2a0766 to your computer and use it in GitHub Desktop.
Naismith's rule with Aitken-Langmuir corrections in Matlab, units in km and h
function [w, t, slope] = naismith_al(length, ascend, base_speed)
if ~exist('base_speed', 'var')
base_speed = 4; % km/h
end
slope = ascend/length;
t = length*(1/base_speed);
if slope >= 0
t = t + ascend*(1/0.6);
elseif atand(slope) <= -5 && atand(slope) >= -12
t = t - abs(ascend)*((10/60)/0.3);
elseif atand(slope) < -12
t = t + abs(ascend)*((10/60)/0.3);
end
w = length./t;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment