Monday, October 5, 2015

MATLAB Homework 4

Problem 1


   For the first problem, we observe some mechanics of materials. We are given a table of a load, in pounds and the corresponding displacement due to the load. There is a correlation between the load and the compression. In order to observe the relationship between the stress and the strain, or the displacement of compression, we solve for the strain and stress using the equations for stress and strain. Since we are working with an array of numbers, we should be getting an array of solutions for the stress and the strain. These arrays will have the same dimension, and, therefore, we are able to get the strain and the stress plotted on a graph. The graph shows that the is a linear relationship at first, then, there is a change. This change occurs at the yield point. The linear slope is the elasticity of the object that is compressed. Using this graph, we are able to see how far we can compress or stretch an object.

Problem 2


   The second problem has us working with polar graphs. The first graph is a three flower pedals with a large radii and 8 flower pedals half the radius of the overlaid 3 flower pedals. We can acheive this picture using the hold on command. This command allows us to put multiple functions ont eh same graph. The second graph is a heart. The third is a 6 pointed star. This is achieved by plotting less points. With less points, we can achieve straight lines. The last graph builds off of the idea of the star. The only difference is how the lines connect from on position to another. 

Problem 3


   The third problem has us look at the transistor count for the Intel processor on a periodic basis. In the program, I create an array of the years and time in years of 2 year intervals to match the year array. Next, we use the formula that calculates the transistor count. This is a theoretical model. The theoretical model will be used to compare to the actual count. Before we compare, though, we create some graphs for the transistor count vs. time. We utilize the different ways to plot, such as the semilog or the loglog plots.


   Once the graphs of the theoretical values are plotted, we then choose the type of graph we want to show to compare the two slopes. Since we want to see a simple representation of the rate at which the transistors increase with time, we force the data to plot a linear graph using the loglog plot. The plots, by comparison, show that the transistors increase at the same rate. This means that the theoretical equation does a good job n predicting the transistor count. 


MATLAB Day 5

Graphing By Plots


   We go back to the idea of plotting on MATLAB. We can create a variable and make it into an array and create a second variable and make it into an array. Using the plot function, we can plot a graph based on the arrays. One condition is that the arrays have to be the same size. The plot command plots the x-axis first, then the y-axis. Once we plot the graph, we can add some details. We can use the title command to give the graph a title and the xlabel function to label the x-axis. The ylabel function works the same way.


   We establish an array of angles so that we can graph the functions of sine and cosine with respect to the angles of the array. This introduces the subplot feature that allows us to look at two graphs, simultaneously, on the same window. This is a good feature for comparison purposes.


   The next feature for plotting is the hold on/off command. Selecting to hold on during plotting allows us to plot a second graph, a third, a forth, and so on, on the same graph, until we select the hold off command.


   We can also alter the graph by altering the point designs, the line design, and color of the line. We make these alterations within the plot command.



   In the next problem, we look at saturation vapor pressure. The relationship between the pressure and the temperature is given by a logarithmic. On our white boards, we refined the equation to solve for the saturation pressure, given the other pieces of information.


   We create an array of temperature values in kelvin for the problem on the whiteboard.


   More values are created in variables. We, then, use the given values to find the saturation pressure using the equation derived on the whiteboard. Since we are working with some arrays of numbers, we have to remember to account for the dot multiplication. For the amount of temperatures there are, the result displays the saturation pressures for every temperature.


   After all of the values for saturation pressure have been calculated, we plot the graph pressure vs. temperature. The graph correctly shows us an exponential change as the temperature increases.


   The next problem involves a standard projectile motion problem. The projectile in this problem shoots at an angle on a level surface and lands on the same height. Using the x-component and the y-component, we manipulate the kinematics equations t solve for the range a projectile travels.


   We start the problem on the whiteboard by giving an initial velocity of value 100. We are to create a simple program that calculates the range an object travels at angles launched from 0 to 45 degrees.


   Once the givens have been established, we create the equation to solve for the range a projectile travels at different angles launched. Again, we have to make sure that we account for the arrays that are in the equation.


   We draw the graphical representation of the values we calculated. As the angle increases, a parabolic behavior representing the distance traveled is displayed. The parabolic behavior occurs due to the flight time. We maximize our distance when we attain an angle of 45 degrees, which shows in our graph.


   The ability to do polar graphs is also available in MATLAB. The polar function in MATLAB is reliant on the radial distance, as well as the angular distance, which is how polar is traditionally done. We are able to graph polar graphs seen in calculus classes. To produce smooth curves, we need a large amount of points and radii so that we can graph smooth curves.


   We can make some interesting designs by manipulating the amount of radii and the angle plotted. The less points, the more straight lines that will form when plotting. We can make hearts, flowers, an infinity symbol creating two flower pedals and stars.


   Lastly, we go over some unique plotting abilities in MATLAB. We can plot using the semilog command, which allows MATLAB to find logarithmics of negative numbers and zero, omit these values, and plots around them. This is useful for avoiding errors.

Summary:
   A lot of graphical abilities were defined. We discussed ways to plot many graphs on one window. We also discussed ways to plot multiple lines on the same graph. What we can also do is plot different graphs on different windows. This function is the figure function. We just type Figure(#) where we number the window. We go over some physics problems and plotted the solution. We can also customize the graphs by changing the line color, the points on the line, and the line structure. We finished of by going over the polar graphing and the logarithmic graphing.

MATLAB Homework 3


Problem 1


   For the first problem, we had to create a distance calculator using the coordinate system. The calculator has the user input coordinates on Earth and these coordinates are stored into variables for calculations. This calculator only calculates distance on the norther hemisphere of the Earth. When the user inputs the coordinate of two places, the programs displays what calculations took place. What happens in the program is that the coordinates inputted are converted to spherical coordinates. Once we have the spherical coordinates, we convert these spherical coordinates to rectangular. With these rectangular coordinates, we can do some vector calculations involving the definition of the dot product. The dot product allows us to find the gamma between the two vectors. Once we have the gamma, we can, then, find the distance between the two places using the definition of the arc length, which is the angle in radians times the length of the radius.


   The picture above shows the results of the program for distance calculations

Problem 2

 
   To begin the second problem, we begin by inserting a matrix into MATLAB. We can do this just by using the import command. We can also create a dimensionless matrix in the workspace and make changes to the matrix by copying and pasting the matrix data from excel.


   Using the matrix created, we had to find the maximum values of each column, the minimum values of each column, and the maximum values of the entire matrix. The columns represent the thermocouple temperatures. This problem was done by creating separate arrays from the given matrix and labeling these arrays by the column they represent. One the arrays are created, I am, then, able to mind max values using the max command and minimum values using the min command. To find the max value of the entire matrix, I simply find the max of the entire matrix first. This would give me an array of maximum values. I, then, use the max function, again, to find the max value of the max values. So, I use the max function within the max function.


  The results of the program are displayed in the picture above. The max values of each column are represented by x variables and the the minimum values are represented by y variables. The largest variable shows the largest number of the entire matrix.

Problem 3


   For this problem, we had to create an array whose average was 80 and whose standard deviation was 23.5. We obtain the average by adding 80 to the matrix of random numbers. We obtain the standard deviation of 23.5 by multiplying the array by 23.5.

Problem 4


   We take a look at a circuit problem. The problem has some givens and equations. We simply state the givens and calculate using the equations and the givens. This problem emphasizes imaginary numbers, which are seen in circuit analysis.

Problem 5




   The last problem had us calculate the precipitation of a time period from January 1, 2015 to September 3, 2015. The obtained from the website was a simple 241 by 2. Like the first problem, I broke down the tables columns into arrays. Then, I summed the values for precipitation and found a value in decimeters. We also had to use the first program to compare different stations according to their coordinates and choose the station closest to home.