Find the time when a parabolic function starts to decrease.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Roger L
el 2 de Oct. de 2016
Comentada: Roger L
el 3 de Oct. de 2016
Hello,
My task is to write a script that will find the time when a parabolic function (height, a function of time) reaches its max.
clear all
t=0;
for time=0:0.5:30;
if height(time)>=height(time-0.5)
t=t+0.5;
end
end
disp(t)
height(time-0.5) wouldn't execute so here is my second code
clear all
t=0;
for time=0:0.5:30;
e=0.5:0.5:29;
time2=[0 e];
while height(time)>height(time2)
t=t+0.5;
end
end
disp(t)
this code does not work either. How can i utilize max( ) function in here? And what is the best way to do this kind of loop?
Thanks!
0 comentarios
Respuesta aceptada
Walter Roberson
el 2 de Oct. de 2016
What is height here? If it is a vector then you cannot use height(time) you can only use height(SomePositiveIntegerIndex) . But once you have found the appropriate positive integer index, you can use it to figure out what the corresponding time is.
3 comentarios
Walter Roberson
el 2 de Oct. de 2016
[maxheight, idx] = max(height(time))
where time is a vector. Then time(idx)
Más respuestas (0)
Ver también
Categorías
Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!