Sunday, September 13, 2015

MATLAB Homework 2


Classwork



   These are the problems that were not able to be done in class and was assigned as homework. It required us to factor, find the GCD, find prime numbers, find the factorial, and find the maximum number of ways to arrange a group.

Problem 1 & 2


   In problem 1, we had to use different functions and compare these functions. When finding the square root, we have three different commands to use. One out of the three commands cannot find the square root of a negative number. This command is the nthroot command. If there was a negative number, the command would display an error. These commands can also handle vector calculations.

Problem 3


   For this problem, more commands were used to divide a vector, find the remainder, find the exponential, and the sin of that vector. The commands used are displayed on the picture.

Problem 1 (4)


   In this problem, the population rate needed to be solved. The givens are initially stated as p_o for initial population, r for the rate at which the population grows or decays, and t for the time the population grows or decays. Next, I input the formula to solve for the current population and labeled this variable as current_population.


   The same idea for the last problem is used for this problem as well, except the variables are adjustable. I used the same variables to represent the same things. I, then, use the input command to allow a user to input the following information needed. The input command is also descriptive on the type of information that it requires.


   This shows the results of the previous commands, once the user inputs the information. At the end, there is a statement that shows how many people there are in the amount of years requested at the rate inputted.

Problem 2 (5)


   For problem 3, a set of numbers were given for heat. Using what we know about heat and the rate at which heat is extracted, the number of A/Cs was determined. I started by stating some of the givens and multiplying some of the givens by the amount of objects that emit heat. I added all of the heat together to get a total of heat entering the home. Then, I calculate the amount of A/Cs needed using the amount of heat an A/C can extract and the total heat going in the home. I finished everything with simple statements that organize the results.


   A similar program as the previous one is implemented. The difference is that now the user can input values for the amount of light bulbs and the amount of appliances. This was done by using the input function for the number variables under the light bulb and appliances. 

Problem 3 (6)



   The final problem involved a bit of discrete math. The first command solved for the number of ways to group 4 people. The second command solved for the number of ways to group 28 students in groups of 7. The third command did the same but with consideration of order. The forth command displayed the amount of ways to get hands of 5 in a 52 card deck. The last command displays the chances of getting a royal flush.

No comments:

Post a Comment