I am interested in finding the x value at which the vertical distance between two curves is maximum. I don't know how to do this in Matlab (see the figure below for the graph)

I have my functions defined to be:
y1 = (1 - exp(-5))*exp(-x/50);
y2 = (1 - exp(-5000/1600))*exp(-x/250);
x = 10:300;
Does anyone know how I can locate the maximum vertical distance between these two graphs in the interval 10 to 300? Thank you for your time
[M,I] = max(abs(y1-y2))gives the desired maximum valueMand the corresponding first indexI.