skydiver_switch2

# skydiver_switch2 - t =(0:0.1:20 case 3 t =(0:0.1:20 end v =...

This preview shows page 1. Sign up to view the full content.

Sheet1 Page 1 function [t, v] = skydiver_switch2(m,g,c,t) % Function to calculate skydiver falling speed with % number of inputs determined on the fly. % % Inputs: mass m (kg) % gravity g (m/s^2) % drag coefficient c (kg/m) % time vector (s) % % Outputs: falling speed vector v (m/s) % Check how many parameters the user has input and assign % default values based on that number switch nargin case 0 error('Please rerun the program and enter enter at least one input.') case 1 g = 9.81 c = 0.25 t = (0:0.1:20)' case 2 c = 0.25
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t = (0:0.1:20)' case 3 t = (0:0.1:20)' end v = sqrt(m*g/c)*tanh(sqrt(g*c/m)*t) % Determine if terminal velocity was reached tol = 1e-4 npts = size(v,1) dv = abs(v(npts,1)-v(npts-1,1)) % How can we use a switch statement to print out the correct message? % We need to turn dv into either a string or an integer. if dv < tol message = 1 else message = 2 end switch message case 1 disp('Terminal velocity was researched.') case 2 disp('Terminal velocity was not reached.') end...
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.

Ask a homework question - tutors are online