Your functions have their own name-space where the variables that are defined exists (in addition to the input variables that you feed the functions with). When the functions complete these variables cease to exist, they are no more. To get the results of interest out you have to define (and assign) some output-variables in your function-files. This typically looks something like this:
function [r_out,flag] = position_along_line(l,r0,e_line)
Here a variables r_out and _flag are defined as output from the function and have to be defined in the function. This way your function calculates something and returns the result. You'll have to adjust your "programmes" similarly. One way to get all the results from a programme is to not have it defined as a function but use it as a script - then all of the calculations will be done in the base workspace and exist after the script has finished - the main drawback is that it is easy to develop scripts that rely on other variables to exist without noticing which gives the scrip some hidden dependencies.
Also avoid the "clc, clear all" trope inside functions it is usless, in scripts it is anoying.