Effacer les filtres
Effacer les filtres

What do these steps do?

2 vues (au cours des 30 derniers jours)
Vineet Patel
Vineet Patel le 2 Déc 2018
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

Réponse acceptée

Walter Roberson
Walter Roberson le 2 Déc 2018
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.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by