MATLAB: How to find the maximum point of a line on a plot with multiple lines

graph

Produced a function with 4 equations and then used the plot function to plot them onto a graph (graph and code below).
function dx = Function(t, x)
dx = [0; 0; 0; 0];
m = 0.7;
n = 0.8;
o = 1;
p = 0.4;
dx(1) = -m * x(1)
dx(2) = m * x(1) + n * x(2) - o * x(2);
dx(3) = o * x(2);
dx(4) = p * x(2);
end
and
[t,x] = ode45('Function', [0 20], [400 0 0 0], options);
plot(t,x);
legend('A', 'B', 'C', 'D');
How do I identify the maximum point of line B (red line which rises and falls)?

Best Answer

[mx,i] = max(x(:,2));
tmx = t(i);
hold on; plot(tmx,mx,'*r')