addpath("functions"); % Constants for test a = 3; b = 5; d = 12; w = 1; % Testing all possible bridge positions (0 to d) [bridge_pos, path_distance] = fminbnd(@(x) calc_path(a,b,w,d,x), 0, d)