What do these steps do?

2 次查看(过去 30 天)
Hi All,
Can someone tell me what these steps mean/do? And if theres a way of simplifing the code.
xmax = [];
[t,x] = ode45(f,tspan,x0);
n = find(t>60);
x = x(n,:);
n = length(x(:,1));
k = 1;
k = k+1;
j = 1;
for i=2 : n-1
if (x(i-1,1)) < x(i,1) && x(i,1) > (x(i+1,1))
xmax(k,j)=x(i,1);
j=j+1;
end
end
Any help would be great,
Thank you

采纳的回答

Walter Roberson
Walter Roberson 2018-12-2
Run an ode45 over tspan. Some but not all of the timesteps correspond to times greater than 60; extract the ode values that were generated for those times.
That done, look for local peaks in the first column.
There are other ways to look for peaks, including vectorized ways. findpeaks() is more flexible about what a peak looks like.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by