The (x, y) coordinates of a certain object as a function of time t are given by
ID: 1854447 • Letter: T
Question
Explanation / Answer
CODE USING FOR LOOP % Initialize the minimum distance to the distance at t=0 min_d = (-10)^2 + 144^2; min_t = 0; for t = 0:4 x = 5*t - 10; y = 25*t*t - 120*t + 144; d = x^2 + y^2; if min_d > d min_d = d; min_t = t; end end fprintf('Time for minimum distance = %d ', min_t); fprintf('Minimum Distance = %d ', min_d); CODE WITHOUT USING FOR LOOP d = []; d(1) = (-10)^2 + 144^2; d(2) = (5*1-10)^2 + (25*1*1 - 120*1 + 144)^2; d(3) = (5*2-10)^2 + (25*2*2 - 120*2 + 144)^2; d(4) = (5*3-10)^2 + (25*3*3 - 120*3 + 144)^2; d(5) = (5*4-10)^2 + (25*4*4 - 120*4 + 144)^2; min_d = min(d); min_t = find(d==min_d) - 1; fprintf('Time for minimum distance = %d ', min_t); fprintf('Minimum Distance = %d ', min_d);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.