Maximizing value for an array with integral function.

10 vues (au cours des 30 derniers jours)
Lal
Lal le 20 Fév 2018
Commenté : Torsten le 27 Fév 2018
I have 'time(t)' and 'acceleration(A)' values. t1 and t2 are the lower and upper limits, where (t2-t1 = 10).
f = max{((integration(A,t,t1,t2))^2.5) * (t2-t1)}
Please help me to put this function in my matlab code.
for t1=1:length(t)
for t2=t1:t1+10
f = (((int(A,t,t1,t2)))^2.5)*(t2-t1);
end
end
I am using this for loop, but getting error for integration.

Réponse acceptée

Torsten
Torsten le 22 Fév 2018
Modifié(e) : Torsten le 22 Fév 2018
fmax = -Inf;
for t1=1:numel(t)-10
fmax = max((trapz(t(t1:t1+10),A(t1:t1+10)))^2.5*(t(t1+10)-t(t1)),fmax);
end
fmax
Best wishes
Torsten.
  8 commentaires
Lal
Lal le 27 Fév 2018
Thank you Torsten. I understand now where I am doing mistake. Your suggestion helped a lot.
And one more thing in the result t(i) and t(i+15) is fixed to "t(i+15) - t(i) = 15".
But It can be any point between t(i+15) and t(i).
For example:
t_low = 7
t_up = 10
for f_max = 100
(because of this reason I introduced "i" and "j". As you said its two-dimensional array )
Thanks
Torsten
Torsten le 27 Fév 2018
f_max = -Inf;
for i = 1:85
for j = 1:15
f = (trapz(t(i:i+j),A(i:i+j)))^2.5*(t(i+j)-t(i))
if f > f_max
tlow_max = t(i);
tup_max = t(i+j);
f_max = f;
end
end
end
f_max
tlow_max
tup_max

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by