ECOR 2606 Lecture Notes - Incremental Search, European Route E40, Inflection Point
Document Summary
Problem: an object is shot upwards with an initial velocity of v0 m/s. Its height h (in m) after t seconds is given by h v. 1 g r rt e gt r where r is a drag coefficient and g is 9. 81 m/s2. % objectheight calculates height of an object shot vertically. % inputs: v0 = initial velocity (in m/s) % t = time (in s), cannot be zero. >> hfunc = @(t) objectheight (v0, r, t); Another way (works because the function can deal with a vector of times): Yet another way (doesn"t require function to handle vectors): >> h = ones (size(t)); % preallocate for efficiency. >> for i = 1 : length(t) h(i) = objectheight(v0, r, t(i)); end. >> plot (t,h) s e r t e m t i h g e. >> f = @(t) objectheight(v0, r, t) - 80; >> time1 = fzero (f, [0 2]) time1 =