I cannot explain the difference between -2x + L and -4x+L unless it's just a typo you made. I suggest you ask your instructor.
Otherwise use linspace(0 to make up a vector of x values, and use the max() function. You might use inputdlg() to ask the user for the L value, and the starting and stopping value of x. http://www.mathworks.com/matlabcentral/answers/8626-how-do-i-get-help-on-homework-questions-on-matlab-answers
