Saturday, September 12, 2015

MATLAB Homework 1


Problem 1


   For the first problem, I declared a bunch of variables that was given for the assignment. Using these variables, I created equations to solve for the total volume and the total surface area. For the surface area, I calculated the surface area of both spheres, then the side of the cylinder, and then the top and bottom of the cylinder. I added the surface areas together but subtracted the surface area of the top and bottom cylinder. This makes sure I don't account for the small area on the sphere that is blocked by the cylinder.

Problem 2


   For the second problem, we had to calculate the temperature of a gas with the given parameters using two different equations. The temperature were similar but not the same. I stated the givens at the top. I found that everything was not in S.I. units but realized that all the units would cancel out in the end leaving a temperature in Kelvin.

Problem 3


    For problem 3, we take a look at a circuit and calculate the response denoted by S. This response has 2 values. After, I created a set of numbers for R and recalculated the response. Some of the numbers shown to be complex numbers.


   I changed the parameters for R to find the smallest value of R that produces a real number for the response. 


   Again, I change the parameters of R. I found that the smallest value for R was 634. But, I realized that I was only checking half of the equation.


I changed the equation and found that it was still at 634. I, also, found that when the R value increases, the S value decreases.

Problem 4


   The forth problem had us evaluating gravitational pull. I stated the values above and created an equation to solve for the force afterward. Then, I created a set of 10 distances that are evenly spaced using the linspace command. I plugged this set of values to the force equation while being mindful that the dot product is needed.

Problem 5


   For problem 5, I am given the amount of miles a group of cars drive a year, the miles they  can drive per gallon, and the rate at which they produce carbon dioxide. I had to find the amount of carbon dioxide produced. This is a simple unit conversion problem. I start with the rate at which cars drove a year and cancel the miles using miles er gallon, leaving me with gallon per yer and cancel out gallons with the rate for pounds of carbon dioxide per gallon. I do the same type of unit conversion for the second part when I solve for the cost of driving each car, but instead of using the amount of carbon dioxide, I use the cost rate.

Friday, September 11, 2015

MATLAB Day 2


Introduction To MATLAB


   We begin experimenting with MATLAB by running some simple calculations. We found that MATLAB can handle these calculation very well, as it follows the order of operations in basic algebra.


   On a whiteboard, we wrote down a calculation for a desired result from the professor. We, then, traded boards with another group. Once our boards were traded, we inputted exactly what was written on the white board. The white board we received did not properly write their arithmetic so that MATLAB could solve it correctly. This demonstrates that MATLAB is sensitive about how calculations are inputted.


   We start taking a look at simple matrices. First, we input a matrix defined as B two different ways. One way, we use commas, while we just use spaces for the second way. Both methods were defined by B. We found that either way produces the same exact matrix. By exact, we mean that the matrix has double data type and takes up the same amount of space. After, we state a 3 by 4 matrix C using the semi colon. Semicolons allow us to move to the next row of a matrix.



   We take a look at some plotting abilities that MATLAB has. By defining x to be a simple matrix set and y to be a different matrix set, we use the plot function to plot a liner graph. The graph displays a bunch of values and a line. After, we go over some of the ways to create good variables. Variables are important because it allows other programmer to get an idea  of what the variable means. In this case, different variables are created to calculate area, surface area and volume. Also, by placing a semi colon at the end of the statement, MATLAB is suppressed by not displaying or restating what was written in the command window.

Less Typing For Less Errors


   We continue practicing by stating variable and solving for a function, but we do so a different way. To avoid any errors in calculation, it is best to do as little typing a possible. We are able to do this if we see any common pieces of arithmetic in the equation and just create a simple variable for that piece, that way, instead of typing so much arithmetic over and over again, we can type something like A. It is also shown that the letter a was used twice. MATLAB recognizes capital and lowercase as different characters and therefore, we are able to use the same letter twice as a variable.


   We go over an ideal gas problem next. The idea here is to do as little typing as possible again. We do this when we have to change the temperature. We do this by pressing the up key on the keyboard. We we press the up key, we are able to refer back to the previous commands we inputted and reuse them. This saves us from make any calculation errors by pressing fewer keys.


   In MATLAB, we can generate a set of numbers using different commands. The first command uses colons in between numbers. For example, by typing 0:2:10, we are able to generate a set of numbers between 0 and 10 going by twos. This command requires the first number first, the last number last, and the type of arrangement for the the numbers in between in the middle. We also use a command called linspace. This command allows us to choose the first number, then the last number, and the spacing of these numbers. For example, the numbers between 10 and 20 with five spaces in between is generated in the picture. This command calculates the numbers in between and these numbers are evenly spaced. The final command is the logspace command. This commant works similar to the linspace, excect it deals with orders of ten. The first input would be the first power of ten. The second input would be the second power of ten. We are only putting the powers when inputting. For example, if we want our first number to be 100, we input 2 for 10 to the power of 2. The last number, like linspace, is the spacing in between the two values. Also, we are able to clear all of the previous data from before by typing "clear" and we are able to work on a fresh page by typing "clc".

Matrix Algebra



MATLAB is great when it comes to matrix calculations. When stating 2 matrices, it is important to remember the principles for matrix algebra. For example, when we multiply two matrices together, we have to distinguish it by telling MATLAB it is a dot product calculation. We can do this by putting a period in front of the multiplication symbol. MATLAB, then does the calculations. If this is not done, MATLAB will state an error. We get some practice with matrix calculations by knowing when to implement the period.


   MATLAB can also transpose a matrix. In order to transpose a matrix, a apostrophe needs to be put immediately after the variable that represents the matrix. This is useful, not only for linear algebra aspects, but for creating neat tables.

Computational Exercises



   This exercise was in reference to the tragic event that took place on mars, when the Mars Climate Orbiter burned up in the orbit of Mars due to conversion errors, costing a great amount of money. We use our white boards to plan how we would tackle the problem on MATLAB. We converted pounds to newtons and created a table for comparison. This demonstrates how easily this could have been avoided. MATLAB was able to convert using minimal commands. Also,, MATLAB has the ability to guess what commands a person really wanted but did not get because of typo errors. Not only that, it retypes everything and all a person has to do is press enter.



   The final problem to solve involved a conversion between miles per hour to velocity. On our white board, we come up with a way to solve the problem with the givens. We calculate the answer by hand and compare this calculation to the answer on MATLAB. With the given information, we had to find the coefficient of drag with at a certain speed and at many different speeds. This was done fairly easily with MATLAB.

Summary:
   Today, we went over some of the basic computational aspects of MATLAB. We found that MATLAB follows the order of operations. We, also, found that MATLAB contains the ability to plot a graph. MATLAB specializes with matrices and we saw a glimpse of how powerful MATLAB is when it comes to matrix calculations by crating and transposing matrices, multiplying them using the dot product, and even coming up with a set of numbers. We are able to utilize MATLAB to make conversions between units

Tuesday, September 1, 2015

MATLAB Day 1


Robot Programming Discoveries


We started off by going over some of the ideas for programming a robot. These ideas were done after an exercize that allowed us to be in the same shoes as a robot that was programmed and a person that controlled the robot. We were broken up into pairs (one robot and one controller) and were given about two minutes to create a way to communicate with our blindfolded robot. Once our two minutes were up, we had to guide our robot though an obstacle course in a race with other "robots" to the final destination. We were also observed by our peers, which made comments every time we crashed our robot into something.

Input And Output Data Process


We recieved our first look in how to output data using the givens initially stated. The data we were giver was a sample of temperatures every thirty seconds. We had to calculate the average temperature and plot the temperature vs. time graph. It is also important that we addressed the important assumptions we made because this allows us to later view if the assumptions we made were adequate enough to get adequate results or if we need to alter any programming to account of behavior that needs to be accounted for, such as neglecting air resistance or not.

The Egg Drop


We begin our first assignment, the egg drop, in the same manner as the input/output data process. We had to come up with a way to drop an egg from a height of 12 meters. We created an input/output data chart to determine the critical data at which the egg would break, such as using impulse, momentum, and energy to calculate key final velocities and impact forces. We determined that we needed to create a way to reduce the final velocity, which would reduce the impulse and impact force. Using a bunch of straws and a piece of paper, we created a parachute that would slow down the egg using air drag and result in a smaller velocity.

 We all predicted that our egg would land safely, but we stated some of the possible ways in which our parachute would fail.


This video shows how our egg drops in comparison to the first group. Our egg begins to drop at around 1:30. Our egg appeared to have dropped the safely (more so than every other group) but in the end, our egg ended up breaking because of the last minute accident, when the wind caused the parachute to flip on its side and, thus, making the egg vulnerable. Unfortunately, we only created a mechanism that allowed the straws to absorb most of the impact force on a vertical landing.


This is a picture of our egg inside the parachute, after the egg dropped from 15 meters.

Summary: 
   We went over some of the ideas of programming a robot and what to consider when programming. Then, we talked about the input/output data analysis technique for solving problems, which we would implement in our first assignment of dropping the egg. The idea was to efficiently brainstorm when solving a problem and carefully consider any variables that might have an effect on the solution.