Thursday, October 8, 2015

Blog Post #10 for 10/08

Exercise 1: Data Types and 'Class'

This was a simple exercise showing us how to create a 'single' array rather than double:


This is the workspace produced after running the program above. Notice matrix D is labeled as 'single'



Exercise 2: More Data Types and Class

This was a more in-depth understanding of data types and class, including the integer function and how matlab handles different types of data:


Output for the program (see comments above for explanation)

Workspace formed after running the program. Notice how E (which is double A + single B) is a single class matrix. This means that, by default, Matlab chooses the lowest bit count.



Exercise 3: Characters

In this exercise, we figured out how matlab interprets character strings. We were told to take the word 'matlab' and capitalize it knowing that, in the computer language, capital letters are 32 away form the lower-case letters.


Output for the program



Exercise 4: Logical Data

In this exercise, we learned that logical arrays output a series of 1's or 0's depending on which statements are true or false, respectively. We also learned about the sparse function, which will extract all non-zero information from a matrix and indicate where those data points are located.


Output for the program. P actually output 1000 data points, which is way too long to post on here so I only took the first 10. Notice that z is a 'logic' statement, so 1 means true and 0 means false.

Workspace generated from the program. Notice matrices 'M' and 'z' are of the 'logical' class, meaning they are simply displaying true/false statements.



Exercise 5: Multidimensional Arrays

This was a simple exercise showing how to create multidimensional arrays (Ex: 2x3x5 matrix)


Workspace generated by the program. Notice that 'my_3D_aray' is a 2x3x3 matrix.



Exercise 6: Cell Arrays

In this exercise, we learned how to work with cell arrays, which can be used to create matrices within matrices; allowing you to string together sets of data of different classes.


Workspace generated by the program. Notice matrix D is a 1x3 'cell', which means it contains various types of classes.





Blog Post #9 for 10/06

Exercise 1: Resistor Circuit

In this exercise, we were given a circuit with 5 resistors of varying resistance and were instructed to solve for the current using Maxwell's equations. We were then told to edit the program to allow user input for the resistances of each circuit as well as the power supplied. Shown below is the final program that allows user inputs.



 User inputs as well as the results for the current in each loop.



Exercise 2: Water Desalination

For this exercise, we were given a situation in which a water desalination system takes in a stream of salt water, then filters it so that one line pumps out fresh water, while the other pumps out salty brine. We were instructed to find the mass of the water from each pipe given 100 kg flows into the system.



Output for the program: 



Exercise 3: Statics

In this exercise, we were given a static situation in which a force is applied vertically to the top of a triangular system with a hinge on one side and a roller on the other. We were instructed to solve for the forces on each side of the triangle, as well as the reactive forces at the two bottom points of the triangle.


Output for the program:




HW #10

Problem #1: Solving Systems of Linear Equations

In this problem, we were given a system of linear equations and were instructed to input these equations into a matrix, then solve for the system using the inv() function as well as the back-divide (\) notation. Using the tic/toc feature, we can determine which method is the most time-efficient.




This is the output for the program depicted above:



Problem #2: Chemical Processing

In this problem, we were given a representation of a separation process in which a stream of water, ethanol and methanol flow into a processor and two streams flow out. Some of the variables were missing from the picture, and we were told to solve for the missing variables.


Output for the program:



Problem 3: Statics Problem

For this problem, we were given a static situation in which a force is applied at an angle to the top of a triangular system with a hinge on one side and a roller on the other. We were instructed to solve for the forces on each side of the triangle, as well as the reactive forces at the two bottom points of the triangle.


Output for the program:



HW #9

Problem #1: Composition of Air

The percent compositions and molecular weight of certain elements in air were given in a table. We were instructed to create a matrix of the data and use the dot() function to find the molecular weight of air.


Output for the program:




Problem #2: Bomb Calorimeter

The masses and heat capacities for 4 different materials were given in a table consisting of four calorimeter experiments. We were told to calculate the total heat capacity for the calorimeter in each experiment using matrix multiplication.





Problem #3: Determinant

In this problem, we were given three sets of matrices and instructed to determine whether or not each matrix is invertable. This is done by taking the determinant of each matrix. If the determinant is 0, the matrix is invertable; otherwise, there is no inverse for that matrix.


Output and results for the program are shown below.



Problem #4: Cross Product

In this problem, we were instructed to calculate the moment at two different points on a shelf with a mass hanging off of the corner. This was accomplished by setting up matrices for the direction and force vectors and taking a cross product.


Output for the program


Hw #8

Problem #1: Free fall distance for each planet in the solar system

Given the value of acceleration due to gravity on each planet, we used simple kinematics to determine the free fall distance on each planet over a time from 0 to 100s




Shown below is a graphical interpretation of the free fall distance vs. time data obtained from the Matlab program. The program also outputs a table that is way too big to blog.



Problem #2: 

This was simply a practice of how to manipulate matrices and work with them in Matlab.


Shown below are the results of the matrix manipulations





Problem #3: Magic Matrices

In this problem, we created a magic 5x5 matrix, matrix A, and performed various manipulations on it: 2A, A^2, and A+2. We were then instructed to test each resulting matrix to determine whether or not it is still a magic matrix.

This function was used to test each matrix


This program creates the magic matrix and performs the manipulations. It then calls the 'IsMagic' function in order to determine whether or not the resulting matrix is still magic.



Output from the program.

Blog Post #9 for 10/01

Exercise 1: Dot Product

The image shown below is a simple practice for the dot product function in Matlab. The Price is the price of the food alone; the total price includes tax.






Exercise 2: Finding the angle between two force vectors

The problem statement and solution written on a white board in class is shown below. 



Code used in Matlab in order to solve the problem shown above.


The results are shown below, with the angle in radians as well as degrees.




Exercise 3: Finding the center of mass

In this exercise, we were given a set of components floating around in free space and we were instructed to find the center of mass of the system using Matlab. Shown below is the whiteboard problem statement and hand-written solution.


The image below is the code used in order to solve for the center of mass using Matlab.



Below is the graphical output of the center of mass problem.





Exercise 4: Inverse practice

In this exercise, we were instructed to create three matrices and find the inverse for each one using the inv() function as well as using ^-1 in order to show that both methods yield the same results.


These are the outputs from the exercise: 

Inverse of matrix A


Inverse of matrix B

 Inverse of matrix C



Exercise 5: Moment

In this exercise, we were given two points on an object and a force acting on it and we were instructed to find the moment about each point. We were also instructed to create a user input program that allows the user to enter a force and direction vector to find the moment. Shown below is the problem statement and hand-written example on the white board.


Below is the code used for solving this particular moment problem:


Shown below is the output generated from Matlab. Moment represents themoment about that particular point. iMoment represents the moment based on the user input for force vector and direction vector.