Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.68 KB | None | 0 0
  1. function [] = model_rocket_townsenm(v_rocket, theta)
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. %
  4. %  Programmer(s) and Purdue Email Address(es):Matthew Townsend
  5. %  1. townsenm@purdue.edu
  6. %
  7. %  Section #:017
  8. %
  9. %  Assignment #:5
  10. %
  11. %  Academic Integrity Statement:
  12. %
  13. %       I/We have not used source code obtained from
  14. %       any other unauthorized source, either modified
  15. %       or unmodified.  Neither have I/we provided access
  16. %       to my/our code to another. The project I/we am/are
  17. %       submitting is my/our own original work.
  18. %
  19. % FUNCTION NAME: model_rocket_townsenm
  20. % INPUTS: List them below one line per input argument
  21. %  v_rocket, the intial velocity of the rocket.
  22. %  theta, the angle of elevation that the rocket will be propelled.
  23. % OUTPUTS: List them below line per output argument
  24. % the ouputs are the different heigths at each sencond
  25. %
  26. % The purpose of this function is to map the heigth of a rocket given theta
  27. % and velocity of the rocket at each second.
  28. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  29. t=0; %this is the starting time for t
  30. y=0; %this is the intial height where heigth will begin at 0.
  31. fprintf('For an intial velocity (m/s) of %6.2f and angle of %6.2f degrees \n',v_rocket,theta)
  32. while y >= 0  %heigth must be above 0 in order for the
  33.     dist = (v_rocket*cos(theta))*t; %this is the calculations for distance in meters
  34.     y = (v_rocket*sin(theta))*t-((1/2)*(9.81)*(t^2)); %this is the calculations for height in meters
  35.     fprintf('AT %6.2f seconds, the heigth is %6.2f m and distance is %6.2f m \n',t,y,dist)
  36.     t = t + 1; %this increases time by one second for each loop.
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement