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

3 次查看(过去 30 天)
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)?

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by