Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [] = model_rocket_townsenm(v_rocket, theta)
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Programmer(s) and Purdue Email Address(es):Matthew Townsend
- % 1. townsenm@purdue.edu
- %
- % Section #:017
- %
- % Assignment #:5
- %
- % Academic Integrity Statement:
- %
- % I/We have not used source code obtained from
- % any other unauthorized source, either modified
- % or unmodified. Neither have I/we provided access
- % to my/our code to another. The project I/we am/are
- % submitting is my/our own original work.
- %
- % FUNCTION NAME: model_rocket_townsenm
- % INPUTS: List them below one line per input argument
- % v_rocket, the intial velocity of the rocket.
- % theta, the angle of elevation that the rocket will be propelled.
- % OUTPUTS: List them below line per output argument
- % the ouputs are the different heigths at each sencond
- %
- % The purpose of this function is to map the heigth of a rocket given theta
- % and velocity of the rocket at each second.
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- t=0; %this is the starting time for t
- y=0; %this is the intial height where heigth will begin at 0.
- fprintf('For an intial velocity (m/s) of %6.2f and angle of %6.2f degrees \n',v_rocket,theta)
- while y >= 0 %heigth must be above 0 in order for the
- dist = (v_rocket*cos(theta))*t; %this is the calculations for distance in meters
- y = (v_rocket*sin(theta))*t-((1/2)*(9.81)*(t^2)); %this is the calculations for height in meters
- fprintf('AT %6.2f seconds, the heigth is %6.2f m and distance is %6.2f m \n',t,y,dist)
- t = t + 1; %this increases time by one second for each loop.
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement