finding the time closest to origin
Afficher commentaires plus anciens
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 commentaire
vicente estrada
le 31 Août 2019
why was 4 used for t
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Numeric Solvers dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!