skydiver_for - % Store new solution v(i,1) = vnew end %...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 function [t, v] = skydiver_for(m,g,c,t) % Function to calculate skydiver falling speed % for specified parameter values and time vector % using an iterative, numerical solution with % a for loop. % % Inputs: mass m (kg) % gravity g (m/s^2) % drag coefficient c (kg/m) % time vector (s) % All inputs are passed into the function. % % Outputs: falling speed vector v (m/s) % Iterate the solution based on the number of time points npts = size(t,1) dt = t(2,1)-t(1,1) vnew = 0 v = zeros(npts,1) v(1,1) = vnew for i = 2:npts % Why do we start at i = 2? % Update v vold = vnew dvdt = g-(c/m)*vold^2 vnew = vold + dvdt*dt
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % Store new solution v(i,1) = vnew end % Compare with analytic solution to see how good our final value % of v is. Note that we cannot normally do this, but we will do it % here to develop an understanding of what factors influence the % accuracy of the numerical solution. vtrue = sqrt(m*g/c)*tanh(sqrt(g*c/m)*t(npts,1)) fprintf('The numerical final velocity is %7.4f m/s\n', v(npts,1)) fprintf('and the analytical final velocity is %7.4f m/s.\n', vtrue) Sheet1 Page 2 % We need an initial condition on v - why, and why call it vnew? % Pre-allocate memory for v...
View Full Document

This note was uploaded on 09/05/2011 for the course EGM 3344 taught by Professor Raphaelhaftka during the Spring '09 term at University of Florida.

Page1 / 2

skydiver_for - % Store new solution v(i,1) = vnew end %...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online