MATLAB homework

profileavvhatgihasad
matlab_assignment2_fall2016.pdf

SES 100 Homework – Fall 2015 Matlab Homework #2 DUE: Friday Nov. 18

1) Imagine that you went to the bank and deposited $15,000 in an account that earns 7% interest every year, with each year’s interest being deposited back into the account. Write a MATLAB program that computes the number of years it would take to accumulate $400,000. You should use either a “for” loop with a nested “if” statement, or a “while” loop to solve this problem. Things to consider:

• Rather than starting a new program from scratch, EDIT a program you have or one of the examples.

• Your program must output the final value to the screen (use the “fprintf” commands.)

• Remember that 7% = 0.07 • Use the Matlab Examples handout for hints and help with syntax.

2) A rocket launches with an initial mass of 10,000 kg, an acceleration due to the rocket of 20 m/sec2, and 4,000 kg of fuel. It burns 50 kg of fuel each second. Write a Matlab program to calculate and plot its velocity versus time. Things to consider:

• Use a “for loop” with a nested “if” statement” or a “while” statement to loop through time

• Use the physics equations for velocity and acceleration • Remember to include the force of gravity • Remember to stop firing the rocket when you run out of fuel • Your program must output the final velocity to the screen (use the “fprintf”

commands.) and make a plot

Extra Credit: In reality the acceleration of a rocket isn’t a constant – the force that it exerts is. For extra credit, modify your program to use a constant rocket force of 100,000 N. In this case you will need to account for the changing mass of the rocket to compute its acceleration – which will then change with time.