finding the time closest to origin
Show older comments
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 Comment
vicente estrada
on 31 Aug 2019
why was 4 used for t
Accepted Answer
More Answers (0)
Categories
Find more on Numeric Solvers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!