finding the time closest to origin
Mostrar comentarios más antiguos
I am trying to find the time and distance at which the object is closest to the origin where the x and y coordinates vary with time. THis is what I have. But, something seems to be not working. First I used a point at time t=4 and used for loop to check for all times from 0 to 4.
disp('Finding the closest point')
t=4;
x=5*t- 10;
y= (25*t^2)- 120*t+144;
point =sqrt(x^2+y^2);
for t=0:0.1:4;
x= 5.*t-10;
y= 25.*t.^2- 120.*t+144;
point1= sqrt(x^2+y^2);
if point1<point
xmin=x;
ymin=y;
tmin=t;
end
end
a= 5*tmin- 10;
b= (25 *tmin^2)- 120*tmin +144;
dist=sqrt(a^2+b^2);
disp(dist)
disp(tmin)
1 comentario
vicente estrada
el 31 de Ag. de 2019
why was 4 used for t
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Numeric Solvers en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!